2

I am trying to convert information in a route that is in JSON format into JMS format so that I can send it to a topic.

Looking at the docs, I see:

from("activemq:My.Queue").
  marshal().json(JsonLibrary.Jackson).
  to("mqseries:Another.Queue");

Is it correct to interpret here that we have marshalled the message from the queue into JSON, then when sending it to the other queue, it has been converted back to a JMS message? If not, how can we achieve this conversion using the Java DSL? Further, is it possible to add key-value pairs to the JSON along the Camel route?

Thanks.

1 Answer 1

1

You can pass any kind of data to a JMS queue. The marshal().json suggests that the data in My.Queue was a java object, which was converted into json format. The Another.Queue queue is receiving a json object.

You can also transform your data anyway you want before passing the data to the consumer.

Sign up to request clarification or add additional context in comments.

2 Comments

What would be the difference between sending the data without marshalling it first and sending it after marshalling? Do we convert to JSON for convenience?
I think that example was just showing you could convert to json without much of a hassle. You could just as easily remove the marshal to json, which means your camel route will be picking pojos from My.Queue and just transferring those to Another.Queue

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.