到錯誤處理程序我有限定doTry-doCatch塊的路由。當在doCatch塊中處理異常時,我希望將它傳播到錯誤處理程序,以確保在本地處理消息後將消息添加到死信隊列中。問題是我無法傳播到錯誤處理程序工作(「defaultErrorHandler called!」不會被打印到控制檯)。我也嘗試了onException,但也沒有運氣。異常不會傳播在Apache的駱駝
任何提示不勝感激。 問候,奧利弗
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
errorHandler(deadLetterChannel("ref:myDLQ")
.log("defaultErrorHandler called! ${body}"));
final RouteDefinition route = from("seda:queue.inbox");
route
.doTry()
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("throwing ex");
throw new IllegalArgumentException("test");
}
})
.doCatch(Exception.class)
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("handling ex");
route.log(LoggingLevel.ERROR, "Exception in route: ${body}");
throw new IllegalArgumentException("rethrow");
}
})
.log("Received order ${body}")
.to("mock:queue.order");
}
};
}
我曾與處理(假)試圖做手工的doCatch。它被棄用,也沒有工作。但是,無論如何感謝:-)。您提供的鏈接非常有用。 – OlliP