doTry-doCatch ブロックを定義するルートがあります。例外が doCatch ブロックで処理されるとき、ローカルで処理した後にメッセージが確実にデッド レター キューに追加されるように、例外をエラー ハンドラーに伝達する必要があります。問題は、エラー ハンドラーへの伝達を機能させることができないことです ("defaultErrorHandler が呼び出されました!" がコンソールに出力されません)。onException も試しましたが、うまくいきませんでした。
どんなヒントでも大歓迎です。よろしく、 オリバー
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");
}
};
}