我有一个使用“direct-vm”调用另一个Camel端点的Camel Route。在第二个Camel Route的末尾,我通过编组和序列化返回一个自定义对象“SelectResponse”。在第一个Camel路线中,我正在解组它并将其序列化。在解组之后,我正在尝试将自定义对象转换为JAXB对象。
First Camel Route
from(endpoint)
.routeId(ROUTE_ID)
.inOut("validator:classpath:xsd/abcd.xsd")
.convertBodyTo(SelectRequest.class)
.marshal().serialization()
.inOut(selectDomainServiceURI)
//.unmarshal().serialization()
.convertBodyTo(SelectRS.class)
.convertBodyTo(String.class)
.end()
第二骆驼路线
from("direct-vm:SelectDomainRoute")
.routeId(this.getClass().getName())
.unmarshal().serialization()
.bean(selectRequestProcessor)
//.marshal().serialization()
.end()
在这条骆驼路线中,我遇到了两个问题,如下: 首先,在解组时,camel正在抛出ClassNotFound Exception。为了克服它,我在第二条路线停止了编组,并在第一条路线中停止了解编。执行此操作后,将删除ClassNotFound异常,但Camel无法找到将自定义返回对象转换为JAXB对象的正确转换器方法。 我的转换器有以下方法 -
@Converter public static SelectRS toSelectRS(SelectResponse selectResponse, Exchange exchange) throws Exception {
return domainToJaxbObjectConverter.convert(selectResponse);
}
但是这个方法没有被调用,它抛出了以下异常 -
org.apache.camel.InvalidPayloadException: No body available of type: com...SelectRS but has value: com...SelectResponse@7c06d219 of type: com...SelectResponse on: Message: com...SelectResponse@7c06d219. Caused by: No type converter available to convert from type: com...SelectResponse to the required type: com...SelectRS with value com...SelectResponse@7c06d219. Exchange[Message: com...SelectResponse@7c06d219]. Caused by: [org.apache.camel.NoTypeConversionAvailableException - No type converter available to convert from type: com...SelectResponse to the required type: com...SelectRS with value com...SelectResponse@7c06d219]
有关Camel unmarshaling错误和Camel转换器错误的任何帮助都表示赞赏。