Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[json-serialize-action] does not work as intended #652

Closed
lburgazzoli opened this issue Dec 22, 2021 · 11 comments
Closed

[json-serialize-action] does not work as intended #652

lburgazzoli opened this issue Dec 22, 2021 · 11 comments

Comments

@lburgazzoli
Copy link
Contributor

I have the following route that mimics what the json-serialize-action action is expected to do:

- from:
    uri: "kamelet:timer-source"
    parameters:
      period: "1s"
      message: '{ "msg": "Hello Json" }'
    steps:
    - marshal:
        json: 
          library: Jackson
          unmarshalType: "com.fasterxml.jackson.databind.JsonNode"
    - set-header:
        name: "Content-Type"
        constant: "application/json"
    - to: "log:info?showAll=true&multiline=true"    

But when running it, the type of the body is byte[]instead of JsonNode:

2021-12-22 10:33:18.849  INFO 47060 --- [           main] o.a.c.m.BaseMainSupport                  : Auto-configuration summary
2021-12-22 10:33:18.853  INFO 47060 --- [           main] o.a.c.m.BaseMainSupport                  :     camel.main.name=CamelJBang
2021-12-22 10:33:18.853  INFO 47060 --- [           main] o.a.c.m.BaseMainSupport                  :     camel.main.shutdownTimeout=5
2021-12-22 10:33:18.853  INFO 47060 --- [           main] o.a.c.m.BaseMainSupport                  :     camel.main.routesReloadEnabled=false
2021-12-22 10:33:18.853  INFO 47060 --- [           main] o.a.c.m.BaseMainSupport                  :     camel.main.routesIncludePattern=file:r.yaml
2021-12-22 10:33:18.853  INFO 47060 --- [           main] o.a.c.m.BaseMainSupport                  :     camel.component.kamelet.location=classpath:/kamelets,github:apache:camel-kamelets/kamelets
2021-12-22 10:33:19.072  INFO 47060 --- [           main] o.a.c.i.e.AbstractCamelContext           : Routes startup (total:2 started:2)
2021-12-22 10:33:19.073  INFO 47060 --- [           main] o.a.c.i.e.AbstractCamelContext           :     Started route1 (kamelet://timer-source)
2021-12-22 10:33:19.073  INFO 47060 --- [           main] o.a.c.i.e.AbstractCamelContext           :     Started timer-source-1 (timer://tick)
2021-12-22 10:33:19.073  INFO 47060 --- [           main] o.a.c.i.e.AbstractCamelContext           : Apache Camel 3.14.0 (CamelJBang) started in 192ms (build:30ms init:79ms start:83ms)
2021-12-22 10:33:20.112  INFO 47060 --- [ - timer://tick] info                                     : Exchange[
  Id: 1D192FDF3D9D993-0000000000000000
  ExchangePattern: InOnly
  Properties: {CamelTimerCounter=1, CamelTimerFiredTime=Wed Dec 22 10:33:20 CET 2021, CamelTimerName=tick, CamelTimerPeriod=1000, CamelToEndpoint=log://info?multiline=true&showAll=true}
  Headers: {CamelMessageTimestamp=1640165600078, Content-Type=application/json, firedTime=Wed Dec 22 10:33:20 CET 2021}
  BodyType: byte[]
  Body: "{ \"msg\": \"Hello Json\" }"
]
@lburgazzoli
Copy link
Contributor Author

Should it be unmarshalinstead of marshal?

@lburgazzoli
Copy link
Contributor Author

@oscerd @davsclaus what do you think ?

@oscerd
Copy link
Contributor

oscerd commented Dec 22, 2021

I think so. Do we need this sorted for cutting the release again?

@lburgazzoli
Copy link
Contributor Author

would be nice, but I then don't know what to do with json-deserialize-action.kamelet.yaml

@oscerd
Copy link
Contributor

oscerd commented Dec 22, 2021

@nicolaferraro can you please shed some light on the serialize/deserialize configuration?

@davsclaus
Copy link
Contributor

Every time you use a data format / json etc then its like flipping a coin, if its marshal or unmarshal.

@davsclaus
Copy link
Contributor

yeah it should be unmarshal, when you want to jackson to bind data to POJOs

when you use marshal then it takes "whatever" and writes that as an output stream (eg byte[] etc)

@davsclaus
Copy link
Contributor

2021-12-22 12:10:55.270 INFO 23227 --- [ - timer://tick] info : Exchange[
Id: 9056CFCD5C7172F-0000000000000003
ExchangePattern: InOnly
Properties: {CamelTimerCounter=4, CamelTimerFiredTime=Wed Dec 22 12:10:55 CET 2021, CamelTimerName=tick, CamelTimerPeriod=1000, CamelToEndpoint=log://info?multiline=true&showAll=true}
Headers: {CamelMessageTimestamp=1640171455267, Content-Type=application/json, firedTime=Wed Dec 22 12:10:55 CET 2021}
BodyType: com.fasterxml.jackson.databind.node.ObjectNode
Body: {"msg":"Hello Json"}
]

@lburgazzoli
Copy link
Contributor Author

lburgazzoli commented Dec 22, 2021

given that we have workaround now by using the json-serialize/deserialize action and that we may need to discuss the correct behavior a little bit more, I think we can start a release vote for 0.6 and leave this open.

@oscerd @davsclaus what do you think ?

@oscerd
Copy link
Contributor

oscerd commented Dec 22, 2021

+1 for releasing

@davsclaus
Copy link
Contributor

okay

@oscerd oscerd closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants