Multicast
The Multicast allows to route the same message to a number of endpoints and process them in a different way. The main difference between the Multicast and Splitter is that Splitter will split the message into several pieces but the Multicast will not modify the request message.
Example
The following example shows how to take a request from the direct:a endpoint , then multicast these request to direct:x, direct:y, direct:z.
Using the Fluent Builders
from("direct:a").multicast().to("direct:x", "direct:y", "direct:z");
If you want to aggregate the whatever the incoming messages or outgoing messages within the multicast, here is an example
Using the Fluent Builders
from("direct:parallel")
.multicast(new BodyOutAggregatingStrategy(), true).setThreadPoolExecutor(tpExecutor)
.to("direct:x", "direct:y", "direct:z");
from("direct:sequential").multicast(new BodyOutAggregatingStrategy()).to("direct:x", "direct:y", "direct:z");
from("direct:x").process(new AppendingProcessor("x")).to("direct:aggregater");
from("direct:y").process(new AppendingProcessor("y")).to("direct:aggregater");
from("direct:z").process(new AppendingProcessor("z")).to("direct:aggregater");
from("direct:aggregater").aggregator(header("cheese"), new BodyInAggregatingStrategy()).
completedPredicate(header("aggregated").isEqualTo(3)).to("mock:result");
For further examples of this pattern in use you could look at one of the junit test case![]()
Using This Pattern
If you would like to use this EIP Pattern then please read the Getting Started, you may also find the Architecture useful particularly the description of Endpoint and URIs. Then you could try out some of the Examples first before trying this pattern out.