3 Replies Latest reply on Dec 29, 2008 1:15 AM by beve

    Content based routing based on message property

      Hi All,
      i have a situation where i wanted to use cbr.
      I have three services
      1. SendDataService
      2. FTPService
      3. SMTPService

      SendDataService extracts data and transforms it in client specific format and after transformation it has to route the message to FTPService/SMTPService, the decision maker is the message property "CommunicationMode".
      If CommunicationMode is FTP then message should be routed to FTPService and if CommunicationMode is SMTP then message should be routed to SMTPService.

      So can any one provide me a sample drools rule which checks for message property?

      Thanks in advance...

        • 1. Re: Content based routing based on message property
          beve

          Hi,

          something like this should work:

          #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
           destinations.add("FTPService");
          end



          regards,

          /Daniel

          • 2. Re: Content based routing based on message property

            Thanks a ton beve,
            It worked :-)
            This is my final code

            #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


            I have one question
            "Where can i found some good documents to understand the syntax of Drools?"
            i had searched on web but couldn't find any good document.

            • 3. Re: Content based routing based on message property
              beve

              Great, glad to hear that it worked!

              Where can i found some good documents to understand the syntax of Drools

              This can be found in the Drools user guide : http://www.jboss.org/drools/documentation.html

              regards,

              /Daniel