--- (John Ellis) ---One of Camel's greatest strengths is the explicit support for Enterprise Integration Patterns. Drools itself is particularly well suited to work alongside Camel to implement two commonly used integration patterns: the Content Based Router and the Dynamic Router. Both patterns leverage the ability of a Drools Endpoint to rapidly evaluate properties of a message, while the Dynamic Router can also integrate the Drools Policy as a dynamic rule based on feedback from a control channel.

The Camel routes required for message routing do not differ much from the previous Drools Endpoint example. You may even be able to omit the Drools Policy if you wish to inspect only the headers of messages being routed instead of interrogating the body of each message. For example, a DRL could be defined that takes action on inbound messages such as:

Here the custom header “OPERATION” is evaluated to see if it is set to the value “WRITE” or “READ.” Depending on the value of this header, a routing slip is defined for the message. The Routing Slip is another Enterprise Integration Pattern supported by Camel that may contain one or more URIs. The message is then sequentially sent to each URI defined.

Here we explicitly inform Camel that routing slips are defined as values within the “routingSlip” header and each URI is delimited by a # character. The headers set within the DRL are then interpreted as each message exits the Drools endpoint.

Content based routing with a Drools Endpoint offers several advantages over Camel's default implementation. The DRL format itself allows routing to be specified more succinctly than Sprint DSLs or Camel RouteBuilders. Conditional operations are also evaluated more efficiently within Drools and are thread-safe, allowing a high volume of messages to be routed concurrently.