user518066
user518066

Reputation: 1417

camel suspends route using control bus

I have camel route which suspends the route using control bus on exception.

onException(Exception.class).maximumRedeliveries(1).onRedeliveryRef("controlBusProcessor");
from("quartz2://myGroup/myTimerName?trigger.repeatInterval=2000&trigger.repeatCount=0")
                    .routeId("myRoute")
                    .process(simpleProcessor)
                    .to("stream:out")

The route initially calls a simple processor which raises an Exception, the onException has a redeliveryRef which calls a control bus processor which suspends the route, however it still calls simple processor to redeliver the message.

If the route is suspended, why is simple processor is still called, should it not wait until the route resumes?

Upvotes: 1

Views: 1046

Answers (2)

Claus Ibsen
Claus Ibsen

Reputation: 55750

No the route will complete its in-flight messages before being suspended. In your custom redelivery processor, you can mark the exchange to stop continue routing by setting the property on the exchange with Exchange.STOP=true.

See how the StopProcessor does that: https://github.com/apache/camel/blob/master/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java

Upvotes: 1

Souciance Eqdam Rashti
Souciance Eqdam Rashti

Reputation: 3193

I suspect the redelivery starts at the point of failure which is at .process(simpleProcessor). But if you only want to suspend the route why not just add .onException(Exception.class).to("controlBusProcessor")

Upvotes: 0

Related Questions