Stop processing in case of exception - 6.3

Talend ESB Mediation Developer Guide

Talend Data Fabric
Talend Data Services Platform
Talend ESB
Talend MDM Platform
Talend Open Studio for ESB
Talend Real-Time Big Data Platform
Design and Development
Talend ESB

The Multicast will by default continue to process the entire Exchange even in case one of the multicasted messages will throw an exception during routing. For example if you want to multicast to 3 destinations and the second destination fails by an exception. What Camel does by default is to process the remainder destinations. You have the chance to remedy or handle this in the AggregationStrategy.

But sometimes you just want Camel to stop and let the exception be propagated back, and let the Camel error handler handle it. You can do this by specifying that it should stop in case of an exception occurred. This is done by the stopOnException option as shown below:

      .stopOnException().to("direct:foo", "direct:bar", "direct:baz")
   from("direct:bar").process(new MyProcessor()).to("mock:bar");

And using XML DSL you specify it as follows:

    <from uri="direct:start"/>
    <multicast stopOnException="true">
        <to uri="direct:foo"/>
        <to uri="direct:bar"/>
        <to uri="direct:baz"/>
    <to uri="mock:result"/>

    <from uri="direct:foo"/>
    <to uri="mock:foo"/>

    <from uri="direct:bar"/>
    <process ref="myProcessor"/>
    <to uri="mock:bar"/>

    <from uri="direct:baz"/>
    <to uri="mock:baz"/>