Dynamic router/Splitter are not the solutions, but Recipient list is.
Having the same question and it seems the original link is broken. Searching DynamicRouterTests.java
leading me to this repo: https://github.com/camelinaction/camelinaction/blob/master/chapter8/dynamicrouter/src/test/java/camelinaction/DynamicRouterTest.java
But I think it only sends to one endpoint at last; it's a choice, not a duplication to multiple endpoints.
Splitter neither. See https://github.com/camelinaction/camelinaction/blob/master/chapter8/splitter/src/test/java/camelinaction/SplitterBeanTest.java
where one Customer is split into 3 departments. But it's duplication on one endpoint, not one message to multiple endpoints.
While Recipient List EIP allows you to appoint several destinations for one message. Check https://github.com/camelinaction/camelinaction/tree/master/chapter2/recipientlist/src/main/java/camelinaction
The main route:
from("jms:xmlOrders").bean(RecipientListBean.class);
// test that our route is working
from("jms:accounting").process(new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("Accounting received order: "
+ exchange.getIn().getHeader("CamelFileName"));
}
});
from("jms:production").process(new Processor() {
public void process(Exchange exchange) throws Exception {
System.out.println("Production received order: "
+ exchange.getIn().getHeader("CamelFileName"));
}
});
And the recipients come from:
public class RecipientListBean {
@RecipientList
public String[] route(@XPath("/order/@customer") String customer) {
if (isGoldCustomer(customer)) {
return new String[] {"jms:accounting", "jms:production"};
} else {
return new String[] {"jms:accounting"};
}
}
private boolean isGoldCustomer(String customer) {
return customer.equals("honda");
}
}
You can see in the example that for each recipient, you can specify what to do afterwards in the route, respectively. Maybe defining universal processing in the main route is also possible.