Versions Compared

Key

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

...

Wiki Markup
{div:class=confluenceTableSmall}
|| Name || Default Value || Description ||
| {{uriDelimiter}} | {{,}} | Delimiter used if the [Expression] returned multiple endpoints. |
| {{ignoreInvalidEndpoints}} | {{false}} | If an endpoint uri could not be resolved, should it be ignored. Otherwise Camel will thrown an exception stating the endpoint uri is not valid. |
| {{cacheSize}} | {{1000}} | *Camel 2.13.1/2.12.4:* Allows to configure the cache size for the {{ProducerCache}} which caches producers for reuse in the routing slip. Will by default use the default cache size which is 1000. Setting the value to -1 allows to turn off the cache all together. |
{div}

Dynamic Router in Camel 2.5 onwards

...

You can also use the @DynamicRouter annotation, for example the Camel 2.4 example below could be written as follows. The route method would then be invoked repeatedly as the message is processed dynamically. The idea is to return the next endpoint uri where to go. Return null to indicate the end. You can return multiple endpoints if you like, just as the Routing Slip, where each endpoint is separated by a delimiter.

Code Block
java
java

public class MyDynamicRouter {

    @Consume(uri = "activemq:foo")
    @DynamicRouter
    public String route(@XPath("/customer/id") String customerId, @Header("Location") String location, Document body) {
        // query a database to find the best match of the endpoint based on the input parameteres
        // return the next endpoint uri, where to go. Return null to indicate the end.
    }
}

...

The simplest way to implement this is to use the RecipientList Annotation on a Bean method to determine where to route the message.

Code Block
java
java

public class MyDynamicRouter {

    @Consume(uri = "activemq:foo")
    @RecipientList
    public List<String> route(@XPath("/customer/id") String customerId, @Header("Location") String location, Document body) {
        // query a database to find the best match of the endpoint based on the input parameteres
        ...
    }
}

...

Include Page
Using This Pattern
Using This Pattern