8 Replies Latest reply on Jul 26, 2010 2:37 PM by mvecera

    Content based routing - using message property

    skumarraju

      Dear Experts,

       

      is it possible to route the message by interpreting the message properties?

       

      have tried with the below code extract howerver it did not work. requirement is to make decision on the subscriptionAction property. which is set in the first action of the Action pipeline?

      examples for CBR rules are highly appreciated. have tried using JBOSS content based routing as it didn't work went ahead and implemented my own content based router(pure java logic) which makes use of service invoker for routing. however it lacks the synchrnous behaviour though i can use deliverSynch method of service invoker somehow not feeling comfortable with it. want to make use of standard content based router of JBOSS.

       

      rule "Add Routing Rule using XPATH"
      action = Message.getProperties().getProperty("subscriptionAction");
      Log : "subscription is" + action;
      System.out.println("ADD ROUTING rule is being evaluated");

       

          when
          Log : "ADD ROUTING rule is being evaluated";
          sa : SubscriptionAction( subscriptionAction == "ADD")
          Log : "ADD ROUTING rule is being evaluated" + sa ;
                
          then
              System.out.println("ADD ROUTING rule is selected");      
              destinations.add("add");           
      end

       


      Regards,

      -Shravan

        • 1. Re: Content based routing - using message property
          skumarraju

          Can someone answer pls?

          • 2. Re: Content based routing - using message property
            mvecera

            Hello Shravan,

             

            search ESB Services Guide for object-paths (http://docs.jboss.org/jbossesb/docs/4.8/manuals/html/ServicesGuide.html). You can map your message property to be validated against defined rules. I'd better use regexp router for your simple scenario.

             

            Regards,

            Martin Vecera

            SOA Platform QE

            JBoss by RedHat

            • 3. Re: Content based routing - using message property
              tfennelly

              Could also look at extending the ContentBasedWiretap class, injecting a new implementation of the ContentBasedRouter interface (or its abstract impl AbstractPropertyRulesRouter).

              • 4. Re: Content based routing - using message property
                skumarraju

                Thanks for the reply.

                I'm sorry for coming up with same question. althogh have tried the instructions provided in the guides couldn't make it to work.

                 

                below is my service configuration

                <service category="MyFirstCBRServicesESB" description="ESB Listener" name="FirstCBRServiceESB">
                   <listeners>  
                    <jms-listener busidref="quickstartGwChannel" is-gateway="true" name="the-gateway"/>
                    <jms-listener busidref="quickstartEsbChannel" name="XPathContentBasedRouter"/>
                   </listeners>
                   <actions mep="OneWay">


                <action class="org.jboss.soa.esb.samples.quickstart.simplecbr.TestAction" name="test"/>

                <action  class="org.jboss.soa.esb.actions.ContentBasedRouter" name="ContentBasedRouter">
                <property name="cbrAlias" value="Regex"/>
                <property name="destinations">
                <route-to service-category="ExpressShipping" service-name="ExpressShippingService" expression="?" />
                <route-to service-category="NormalShipping" service-name="NormalShippingService" expression="#*222#*" />
                </property>
                     <property name="object-paths">
                <object-path esb="properties.subscriptionAction" />
                </property>
                    </action>
                   </actions>
                  </service>

                Could you pls give me the sample regex rules for interpreting message properties? in my problem, need to write a regex rules such that will evaluate the subscriptionAction feild for routing logic. (ADD,REMOVE,REPLACE,REMOVE and MODIFY are the possible values)

                • 5. Re: Content based routing - using message property
                  skumarraju

                  I actually work arounded the problem or lack of understanding on JBOSS CBR rules by writing a simple service where i could interpret the the subscriptionAction and route the message to a service which is interested in it using ServiceInvoker, however going forward and in the long run for more flexibility thinking to use the framework support extensively.

                  • 6. Re: Content based routing - using message property
                    mvecera

                    Hello,

                     

                    I don't understand what is the problem with the following routes definitions:

                     

                    <route-to service-category="ExpressShipping" service-name="ExpressShippingService" expression=".*ADD.*" />
                    <route-to service-category="NormalShipping" service-name="NormalShippingService" expression=".*MODIFY.*" />

                    <route-to service-category="NormalShipping" service-name="NormalShippingService" expression=".*REPLACE.*" />

                    <route-to service-category="NormalShipping" service-name="NormalShippingService" expression=".*REMOVE.*" />

                    Why cannot that work for you?

                     

                    Martin

                    • 7. Re: Content based routing - using message property
                      skumarraju

                      Thanks again for reply.

                      It says when tried the Regex expressions sent by you.

                       

                      17:24:50,639 ERROR [ContentBasedWiretap] No rule destination(s) [ExpressShipping-ExpressShippingService, NormalShipping-NormalShippingService] were matched, . Please fix your configuration and/or routing rules.

                       

                      here the point I don't understand is, how are we instructing Regex rules executor to interpret the subscriptionAction property (is it thru object-path)

                       

                      -Shravan

                      • 8. Re: Content based routing - using message property
                        mvecera

                        Hello,

                        eventually, I managed to get to it and here is the cause of your troubles: https://jira.jboss.org/browse/JBESB-3389

                        This affects RegEx, and XPath. Drools routing is still fine. So you can use object-path to put a message property into the working memory ang get to it in your rules.

                        Martin