Apache Camel inOut 路由,与 jaxb 交换编组/解组 [英] Apache Camel inOut routes, out exchange marshaling/unmarshaling with jaxb

查看:29
本文介绍了Apache Camel inOut 路由,与 jaxb 交换编组/解组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有这条阿帕奇骆驼路线,

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");

.... 和一个像这样的 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());

前进方向路线上的对象正在出色地编组/解组.但是 setBody 调用导致了 java.io.NotSerializableException.有没有办法将路由配置为在返回的路上使用相同的 jaxb 编组/解组?我的 Command 类包含一些 jaxb 生成的不可序列化的类对象.他们在前进方向上被元帅/解帅处理得很好,如果他们能在回来的路上,那就太好了.我对骆驼比较陌生,所以不确定这是否是最好的方法.

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.

非常感谢.

推荐答案

可以在bean调用后编组

You can marshal it after the bean invocation

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

这篇关于Apache Camel inOut 路由,与 jaxb 交换编组/解组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆