Apache Camel CXF empty response when handling exception

走远了吗. 提交于 2019-12-11 16:14:03

问题


This question is related to the previous one : Apache Camel multicast, exception and Aggregation strategy

I think I missunderstood the problem when asking the previous question.

I try to handle exception I thrown in my route.

.filter(not(successResponsePredicate))
    .to("log:com.sdmo.Error?level="+LOG_LEVEL)
    .transform(simple("Erreur lors de l'appel copyItem"))
    .process(new ConvertCartResponseProcessor())
    .throwException(new Exception("copyItemError"))
.end()

The exception is handled through this code :

onException(java.lang.Exception.class).handled(true).inOut("direct:thrownError");
from("direct:thrownError")
    .to("log:com.sdmo.output?level="+LOG_LEVEL);

My route is started by a cxf endpoint, but when the exception handling route achieved, the body returned to my WS client is empty.

I made several check with the debug mode and the log to ensure that the exception handling code set a response, and if I replace the body (POJO type) by a simple type, I got an unmarshall error when sending the reply.

The last line logged before the reply show the body is well defined :

INFO: Exchange[ExchangePattern:InOut, BodyType:com.access_commerce.cameleonws.cart.AddXMLResponse, Body:com.access_commerce.cameleonws.cart.AddXMLResponse@59dc73f9]

I guess that there is something wrong with my use of the InOut pattern or something like...


回答1:


Drop the handled() method call. It's preventing the exception from percolating up to the CXF endpoint.



来源:https://stackoverflow.com/questions/7446444/apache-camel-cxf-empty-response-when-handling-exception

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