Reputation: 40
I have a dynamic endpoint with .recipientList(), and I want to change the endpoint in case of an exception. Here is my example:
onException(IOException.class)
.maximumRedeliveries(2)
.onRedelivery(urlChangeProcessor)
.process(failureProccessor);
from("direct:foo")
.recipientList(simple("cxf:${exchangeProperty.targetUrl}?dataFormat=POJO"));
On exception before the redelivery the "urlChangeProcessor" updates the "targetUrl" property with the correct URL, but the redelivery attempt is still made to the wrong URL.
Is it not possible to change the target endpoint on redelivery? If not, what is an elegant solution? My current workaround is a doTry/doCatch, changing the property in the doCatch and sending it to the same endpoint again.
I use camel 2.15.3
Thanks in advance!
Upvotes: 0
Views: 639
Reputation: 40
As this is not possible, the solution in my case is to remove the onException
and add a 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"));
Add some conditions so this does not end in an endless loop.
Upvotes: 1