camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From deckerego <decker...@gmail.com>
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:

    
    
    
        routingSlip
    


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"
when
    $message : Message(headers["PURPOSE"] == "USER", headers["OPERATION"] ==
"READ");
then
    $message.setHeader("routingSlip", "mock:queue:user_read");
end

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)
specified.


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

All in all, this seems to be a pretty clean solution for content based
routing with Drools.
-- 
View this message in context: http://camel.465427.n5.nabble.com/Any-interest-in-a-Drools-based-dynamic-router-tp3265110p3291931.html
Sent from the Camel Development mailing list archive at Nabble.com.

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