Apache的骆驼CXF处理异常时

Apache的骆驼CXF处理异常时

本文介绍了Apache的骆驼CXF处理异常时,空响应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题是关系到previous之一:Apache骆驼组播,异常和聚合策略

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

我想询问previous问题,当我missunderstood的问题。

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()

唯一的例外是通过这个code处理:

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);

我的路线是由一个CXF端点​​开始,但是,当异常处理路线获得,主体返回到我的WS客户端是空的。

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

我做了几个检查与调试模式和日志,以确保异常处理code设置一个响应,如果我用一个简单的类型更换阀体(POJO类),我发送时得到了一个和解组错误答复。

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]

我想这有什么不对我使用的InOut模式或东西像...

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

推荐答案

删除该处理()方法调用。这是$ P $渗透,从到CXF端点​​pventing例外。

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

这篇关于Apache的骆驼CXF处理异常时,空响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 23:52