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

﹥>﹥吖頭↗ 提交于 2019-12-11 20:44:38

问题


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 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.


回答1:


You can marshal it after the bean invocation

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


来源:https://stackoverflow.com/questions/5456807/apache-camel-inout-routes-out-exchange-marshaling-unmarshaling-with-jaxb

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!