Multicast – routing the same message to many endpoints
When you want to route the same message to a number of endpoints and have them process the message in different ways, the Multicast EIP is a good choice.
This recipe will show you the default, sequential way to use Camel's Multicast EIP. Chapter 6, Parallel Processing, contains a recipe for using Multicast with concurrency (threads).
Getting ready
The Java code for this recipe is located in the org.camelcookbook.routing.multicast
package. The Spring XML files are located under src/main/resources/META-INF/spring
and prefixed with multicast
.
How to do it...
Use the
multicast
DSL statement, and list the endpoints and processing steps within it.
In the XML DSL, this routing logic is written as:
<route> <from uri="direct:start"/> <multicast> <to uri="mock:first"/> <to uri="mock:second"/> <to uri="mock:third"/> </multicast> </route...