camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deckerego <>
Subject Re: Any interest in a Drools-based dynamic router?
Date Sat, 04 Dec 2010 06:40:19 GMT

To follow up on this subject, I do have this working now with the
5.2.0-SNAPSHOT of drools-camel provided by JBoss. Here's the trick:

My route is specified as:


Where ksession1 is a stateless knowledge session. The "insertMessage" action
for a stateless session will take the org.apache.camel.Message object,
insert it directly into working memory and execute the given rule sets.

The DRL itself is:
rule "User_Read"
    $message : Message(headers["PURPOSE"] == "USER", headers["OPERATION"] ==
    $message.setHeader("routingSlip", "mock:queue:user_read");

Note I'm setting the routing slip header directly on the message and not
updating working memory. The header will then be interpreted by the Camel
route as a routing slip and the message delivered to the endpoint(s)

As a unit test this could be expressed by:
Map headers = new HashMap();
headers.put("PURPOSE", "USER");
headers.put("OPERATION", "READ");
template.sendBodyAndHeaders("direct:drools", "Getting a user!", headers);

All in all, this seems to be a pretty clean solution for content based
routing with Drools.
View this message in context:
Sent from the Camel Development mailing list archive at

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message