处理异常时 Apache Camel CXF 空响应
这个问题与上一个问题相关: Apache Camel 多播、异常和聚合策略< /a>
我想我在问上一个问题时误解了这个问题。
我尝试处理我在路线中抛出的异常。
.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()
异常是通过以下代码处理的:
onException(java.lang.Exception.class).handled(true).inOut("direct:thrownError");
from("direct:thrownError")
.to("log:com.sdmo.output?level="+LOG_LEVEL);
我的路由由 cxf 端点启动,但是当异常处理路由实现时,返回到我的 WS 客户端的正文为空。
我对调试模式和日志进行了多次检查,以确保异常处理代码设置了响应,如果我用简单类型替换主体(POJO 类型),则在发送回复时会收到解组错误。
回复之前记录的最后一行显示正文定义良好:
INFO: Exchange[ExchangePattern:InOut, BodyType:com.access_commerce.cameleonws.cart.AddXMLResponse, Body:com.access_commerce.cameleonws.cart.AddXMLResponse@59dc73f9]
我猜我使用 InOut 模式或类似的东西有问题......
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...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
删除handled()方法调用。它可以防止异常渗透到 CXF 端点。
Drop the handled() method call. It's preventing the exception from percolating up to the CXF endpoint.