Question

I am wondering how I can tell camel to redeliver my message based on business logic.

My route is calling a soap endpoint and, depending on the message returned by the server I need to schedule a retry in a few seconds.

Basically, I have this kind of error handling configured :

onException(Throwable.class)
    .handled(true)
    .processRef("exceptionHandler")
    .redeliveryDelay(5000)
    .maximumRedeliveries(1)
    .to("file://

My exceptionHandler check if the exception is a SOAP Fault, unmarshal it and depending on the content I need to schedule the retry.

Is there anyway of doing that within camel ?

Was it helpful?

Solution

Well, in the end, here is my solution :

from("...")
    .doTry()
        .to("...")
    .doCatch(Exception.class)
         .beanRef("handleException")
    .end()
    .beanRef("handleRegularResponse");

The processor handleException handles the exception, try to understand the issue and then throw a more precise exception. In my case, it can throw 2 types of exception : FunctionalException that do not need to redeliver, and a TechnicalException that I will try to redeliver in a few minutes.

I just have then to declare an error handler for this specific exception :

onException(TechnicalException.class)
    .handled(true)
    .redeliveryPolicyRef("...")
    .useOriginalMessage();

HIH

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top