Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

You will notice an additional @RecipientList annotation on the route method. This turns the method into a Recipient List EIP where the return value is a list of URIs for the recipients (can be String[], List<String>, URI[], etc). This annotation is great for creating custom dynamic Recipient Lists. In this case at step 4 we peek at the city field in the message (using the @XPath annotation) and provide a set of recipients based on that. For folk from London, their files will be sent to file locations for the EMEA region (file:target/messages/emea/...). Others fall into the AMER region (file:target/messages/amer/...).

Tip

If you have messages that are not XML, don't fret! Camel has ways to get information out of arbitrary message payloads. For instance, you can try using the @Bean annotation to peek at the message using your own Java bean.

Code Block

    @Consume(uri = "activemq:personnel.records")
    @RecipientList
    public String[] route(@Bean("cityExtractorBean") String city) {
        if (city.equals("London")) {

Check out Parameter Binding Annotations for more information on this.

After running the example, browse to the target/messages directory to see where the messages were saved.

...