0
votes

I am trying to get a request/reply jms consumer in camel, The incoming message is received and i can see that camel also sends the reply but the message is not marshaled.

I am using interceptors to marshal all messages from and to the activemq endpoint

OsdrDataFormat osdrDataFormat = new OsdrDataFormat();

interceptFrom("activemq:*").unmarshal(osdrDataFormat);
interceptSendToEndpoint("activemq:*").marshal(osdrDataFormat);

(I extend the JacksonDataFormat so i can fill the JMSType when marshalling a message.)

For normal one way exchanges this is working (e.g.)

from("activemq:queue:test").bean(TestComponent.class, "test");
from("direct:test-input").to("activemq:queue:test");

But when i use this route

from("activemq:queue:test").bean(TestComponent.class, "test");

And send a message with a JMSReplyTo message to the test queue (using the activemq management page) i can see that camel did sent the reply message but it is not marshaled to json.

Adding the marshal manually does work, but i prefer to use the interceptor as that would allow me to make a abstract RouteBuilder and add the interceptors by default to each route.

from("activemq:queue:test").bean(TestComponent.class, "test").marshal(osdrDataFormat);

Does anyone know a way to fix this? or maybe a better way to make sure that all messages from and to activemq are marshaled?

i also found this thread: Apache Camel inOut routes, out exchange marshaling/unmarshaling with jaxb but the answer here is to use the manual marshal.

1

1 Answers

0
votes

The interceptSendToEndpoint is only when Camel sends a message to a Camel endpoint - not when a JMS component internally send some JMS message to some JMS destination. Its not the same.