问题
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