我有一个带有 .recipientList() 的动态端点,并且我想在发生异常时更改端点。这是我的例子:
onException(IOException.class)
.maximumRedeliveries(2)
.onRedelivery(urlChangeProcessor)
.process(failureProccessor);
from("direct:foo")
.recipientList(simple("cxf:${exchangeProperty.targetUrl}?dataFormat=POJO"));
在重新传递之前出现异常,“urlChangeProcessor”会使用正确的 URL 更新“targetUrl”属性,但重新传递尝试仍会指向错误的 URL。
是否无法更改重新交付时的目标端点?如果没有,什么是优雅的解决方案?我当前的解决方法是 doTry/doCatch,更改 doCatch 中的属性并将其再次发送到同一端点。
我使用 Camel 2.15.3
提前致谢!
最佳答案
由于这是不可能的,因此我的解决方案是删除 onException
并添加 doTry/doCatch
:
from("direct:foo")
.doTry()
.to("direct:out")
.doCatch(IOException.class)
.process(urlChangeProcessor)
.to("direct:foo")
.end();
from("direct:out")
.recipientList(simple("cxf:${exchangeProperty.targetUrl}?dataFormat=POJO"));
添加一些条件,这样就不会以无限循环结束。
关于java - Apache Camel : modify endpoint on redelivery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47475414/