在camel编组期间出现InvalidPayloadException
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在camel编组期间出现InvalidPayloadException相关的知识,希望对你有一定的参考价值。
我试图从队列中编组java对象,但即使在正确提及对象工厂类之后我也得到了InvalidPayloadException。请在下面找到我的代码:
//JaxB Config
JAXBContext jc = JAXBContext.newInstance(com.ObjectFactory.class);
// POGO configuration in Jaxb component for responsexml insertion
JaxbDataFormat jaxbMarshalXmlInsertion = new JaxbDataFormat(jc);
jaxbMarshalXmlInsertion .setContextPath(MyPojo.class.getName());
jaxbMarshalXmlInsertion .setPartClass(MyPojo.class.getName());
//My Route
from("vm:ResponseQueue").
.log("In response XML body before Marshall-------------->${body}")
.marshal(jaxbMarshalXmlInsertion )
.log("In response XML body After Marshall-------------->${body}")
to(vm:XmlQueue);
//Log(The log before the marshal code is printed correctly in fuse.log)
In response XML body before Marshall-------------->com.MyPojo@2cf745ca
//Excerption I got
InvalidPayloadException: No body available of type: javax.xml.bind.JAXBElement but has value: com.MyPojo@2cf745ca of type: com.MyPojoon: Message[ID-B526DCOK-51386-1514355409371-5-121]. Exchange[ID-B526DCOK-51386-1514355409371-5-122]
谁能帮助我找出我错过的内容并帮助我解决这个问题?
答案
尝试
from("vm:ResponseQueue").
.streamCaching()
.log("In response XML body before Marshall-------------->${body}")
.marshal(jaxbMarshalXmlInsertion )
.log("In response XML body After Marshall-------------->${body}")
to(vm:XmlQueue);
查看更多详情http://camel.apache.org/stream-caching.html
以上是关于在camel编组期间出现InvalidPayloadException的主要内容,如果未能解决你的问题,请参考以下文章
使用 eclipselink 在 JPA 对象上进行 jaxb 编组期间的日期对话错误
将 std::vector 转换为数组然后 p/调用它会在编组期间导致 mscorlib.dll 中的访问冲突异常
检索/保留文件 - 如果在Apache Camel中使用带有onexception的“try .. catch”时catch块捕获到异常