开发者

Apache Camel inOut routes, out exchange marshaling/unmarshaling with jaxb

开发者 https://www.devze.com 2023-02-20 10:07 出处:网络
we have this apache camel route, from(commandDrop).marshal(jaxbDataFormat).to(jmsQueue); from(jmsQueue).inOut("jms:doCommand?requestTimeout=500000");

we have this apache camel route,

from(commandDrop).marshal(jaxbDataFormat).to(jmsQueue);    
from(jmsQueue).inOut("jms:doCommand?requestTimeout=500000");          
from("jms:doCommand").unmarshal(jaxbDataFormat).beanRef("bean");

.... and a bean class like this

class BeanClass {
        public void doCommand(Command command, Exchange exchange){
    {       
        command.run();      
        exchange.getOut().setBody(command);     
    }
}

we are trying to put a message and wait for a reply on the route like this

Object ret = template.requestBody(commandDrop, new TestCommand());

Objects on the route in the forward direction are getting marshaled/unmarshaled splendidly. But the setBody call is causing a java.io.NotSerializableException. Is there a way to configure the route to use the same jaxb marshaling/unmarshaling on the way back? My Command class contain some jaxb- generated class objects that are not serializable. They are handled well by the marshal/unmarshal in the forward direction and would be great if they can be on the way back. Am relatively new to camel so not sure if this is the best way to go about this开发者_运维技巧.

thanks a bunch.


You can marshal it after the bean invocation

from("jms:doCommand").unmarshal(jaxbDataFormat).beanRef("bean").marshal(jaxbDataFormat);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号