hans lux
hans lux

Reputation: 11

Re-Queue/Re-Try a message on failure

I receive a message via a message queue. The message should be persisted and sent to a SOAP endpoint.

When that SOAP endpoint is not available, delivery to that endpoint should be retried until it is sucessfully delivered. Retries should happen with a delay of 10 seconds.

I tried several ways to achieve this.

onException, errorHandler(noErrorHandler), transacted(), rollback()....

What finally works is this.

from(incomingQueue)
                .routeId("incomingQueue")
                .log("sending to partner")
                .wireTap(persistOutgoingUri)
                .doTry()
                .to(sendViaSoap)
                .log("Got Response for SOAP: ${body}")
                .doCatch(IOException.class)
                .log("SOAP delivery failed, requeuing the message...")
                .delay(10000)
                .to(incomingQueue);

But I wonder, if that is the idiomatic way to do it in apache camel.

Upvotes: 0

Views: 50

Answers (0)

Related Questions