Recipient ListThe Recipient List Static Receipient ListThe following example shows how to route a request from an input queue:a endpoint to a static list of destinations Using the Fluent Builders RouteBuilder builder = new RouteBuilder() { public void configure() { from("queue:a").to("queue:b", "queue:c", "queue:d"); } }; Using the Spring XML Extensions <camelContext id="buildStaticRecipientList" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="queue:a"/> <to> <uri>queue:b</uri> <uri>queue:c</uri> <uri>queue:d</uri> </to> </route> </camelContext> Dynamic Recipient ListUsually one of the main resons for using the Recipient List Using the Fluent Builders RouteBuilder builder = new RouteBuilder() { public void configure() { from("queue:a").recipientList(header("foo")); } }; The above assumes that the header contains a list of endpoint URIs. The following takes a single string header and tokenizes it from("direct:a").recipientList(header("recipientListHeader").tokenize(",")); Using the Spring XML Extensions <camelContext id="buildDynamicRecipientList" xmlns="http://activemq.apache.org/camel/schema/spring"> <route> <from uri="queue:a"/> <recipientList> <recipients> <header name="foo"/> </recipients> </recipientList> </route> </camelContext> For further examples of this pattern in use you could look at one of the junit test case Using This PatternIf 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. |