So, after reading some documentation and getting a lot of help from you guys here, I finally implemented a recipient list that chooses the endpoints dynamically (a dynamic recipient list):
In my code, MainApp_A generates reports every 10 seconds, and I want it to send the reports to all the servers at the same time, instead of doing it one by one. Thus I have developed the following route.
MainApp_A
main.addRouteBuilder(new RouteBuilder(){
@Override
public void configure() throws Exception {
from("direct:start").multicast().parallelProcessing()
.beanRef("recipientListBean", "route").end()
.log("${body}");
}
});
RecipientListBean
@RecipientList
public Set<String> route(String body) {
return servers; //returns a collection of several severs
}
I also checked the documentation for the Multicast pattern and the Dynamic route:
Now I have a few questions and I am confused. So I have a few questions:
I recommend you to read EAI patterns by Gregor Hohpe and Bobby Woolf for some background and insight.
http://www.eaipatterns.com/
Multicast allows a hard coded recipient list and recipientList(..)
allows endpoints computed at runtime. Both are "recipient lists".
They will likely be equally efficient, if you don't have a lot of logic (say DB lookups) computing the endpoints in the recipient list - the invocation of the endpoints is likely by far the hardest part for Camel. Anyway - a static "multicast" is more readable.
In Camel, a reason for choosing one construct over another is often readability of the route. You should be able to look at a route and follow what it does (given you know EIP). At least, that's a good aim.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With