Stop
How can I stop continue routing a message?
Use a special filter to mark the message to be stopped.
Using Stop
We want to stop routing a message if the message body contains the word Bye.
In the Content Based Router below we use stop
in such case.
from("direct:start")
.choice()
.when(body().contains("Hello")).to("mock:hello")
.when(body().contains("Bye")).to("mock:bye").stop()
.otherwise().to("mock:other")
.end()
.to("mock:result");
And in XML:
<route>
<from uri="direct:start"/>
<choice>
<when>
<simple>${body} contains 'Hello'</simple>
<to uri="mock:hello"/>
</when>
<when>
<simple>${body} contains 'Bye'</simple>
<stop/>
</when>
<otherwise>
<to uri="mock:other"/>
</otherwise>
</choice>
</route>