Camel:消息监听器中的异常不是在驼峰路径中回过头来的

时间:2013-08-11 22:33:02

标签: apache jms activemq apache-camel

我有一个具有异常处理功能的camel路由,还有一个defaultmessagelistener,它使用amq端点形式的驼峰路由消息。

当在messageMisteage onMessage(消息消息)中抛出异常时,它不会路由回到处理异常的camel

onException(Throwable.class)
            .process(customErrorHandler);

预计:在messagelistener中抛出异常会回到route和porcess errorHandler 实际:捕捉异常

@Override
public void onMessage(Message message) {
try {
//dosomething which throws an exception
    } catch (Exception e) {
        //send back to camel route how??????
onException(Throwable.class)
            .process(customErrorHandler);
    }
}

提前谢谢

1 个答案:

答案 0 :(得分:0)

只是不要在你的onMessage()方法中捕获异常......让它传播回来。如果onMessage是由Camel路由调用的......那么它应该命中你的Camel路由的onException()子句等。

相关问题