[jboss-dev-forums] [Design of JBoss ESB] - Re: Content Based routing using drools

ashok_1979 do-not-reply at jboss.com
Mon Dec 29 00:04:39 EST 2008


Neha, i have implemented this using drools.
Here on the basis of message property i am routing my message to different services. Please have a look if it can help you.


  | #created on: Oct 30, 2006
  | package com.jboss.soa.esb.routing.cbr
  | 
  | #list any import classes here.
  | import org.jboss.soa.esb.message.Message;
  | import org.jboss.soa.esb.message.Properties;
  | 
  | #declare any global variables here
  | global java.util.List destinations;
  | 
  | rule "FTPService Rule"
  |     when
  |         m     : Message()
  |         props : Properties() from m.getProperties()
  |         eval(props.getProperty("CommunicationMode").equals("FTP"))
  |     then      
  |         System.out.println("#########Inside FTPService Rule#########");
  |         destinations.add("FTP-destination");
  | end	
  | 
  | rule "SMTPService Rule"
  |     when
  |         m     : Message()
  |         props : Properties() from m.getProperties()
  |         eval(props.getProperty("CommunicationMode").equals("SMTP"))
  |     then           
  |         System.out.println("#######Inside SMTPService Rule#########");
  |         destinations.add("SMTP-destination");
  | end	
  | 

This is the code from jboss-esb.xml

  | <action name="routingAction" class="org.jboss.soa.esb.actions.ContentBasedRouter">
  | <property name="ruleSet" value="RoutingRules.drl"/>
  | <property name="ruleReload" value="true"/>
  | <property name="destinations">
  | 	<route-to destination-name="FTP-destination" service-category="FTPServiceESBCategory" service-name="FTPServiceESB" />
  | 	<route-to destination-name="SMTP-destination" service-category="SMTPServiceESBCategory" service-name="SMTPServiceESB" />
  | </property>
  | </action>
  | 

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4198676#4198676

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4198676



More information about the jboss-dev-forums mailing list