11 Replies Latest reply on Sep 17, 2008 4:28 PM by mike_ap

    Content Based Routing problem

      I'm setting up an action with content based router (cbr) but I keep getting this error:

      Caused by: org.jboss.soa.esb.services.routing.MessageRouterException: [4] Unable to expand: xpathEquals expr "xmldata/record/status", ""[13,2]: unkno
      wn:13:2 Unexpected token 'xpathEquals'


      my action looks like this:

       <action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="ContentBasedRouter">
       <property name="ruleSet" value="CBRWorkRules.drl"/>
       <property name="ruleLanguage" value="XPathLanguage.dsl"/>
       <property name="ruleReload" value="true"/>
       <property name="destinations">
       <route-to destination-name="ok" service-category="XServices" service-name="Service2" />
       <route-to destination-name="invalid" service-category="XServices" service-name="FaultService" />
       </property>
       </action>
      


      Also, how would I implement something like (not xpathEquals)? What is the proper syntax for this?

      Thank you


        • 1. Re: Content Based Routing problem
          beve

          Hi,

          can you post the contents of 'CBRWorkRules.drl'?

          Regards,

          /Daniel

          • 2. Re: Content Based Routing problem

            Here it is:

            
            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.format.MessageType;
            
            expander XPathLanguage.dsl
            
            #declare any global variables here
            global java.util.List destinations;
            
            rule "Ok Routing Rule using XPATH"
             when
             xpathEquals expr "xmldata/record/status", "1"
             then
             Log : "Job status ok";
             Destination : "ok";
            end
            
            
            rule "Invalid Routing Rule using XPATH"
             when
             xpathEquals expr "xmldata/record/status", ""
             then
             Log : "Empty Job status";
             Destination : "invalid";
            end
            
            


            • 3. Re: Content Based Routing problem
              beve

              Try:

              xpathEquals expr "xmldata/record/status", " "

              Notice the extra space there.

              Regards,

              /Daniel

              • 4. Re: Content Based Routing problem

                I tried putting different values between the quotes but it still seems to complain about the xpathEquals:

                Unexpected token 'xpathEquals'
                


                am I missing any semicolon or something?

                • 5. Re: Content Based Routing problem

                  I also tried replacing xpathEquals with xpathGreaterThan and xpathLessThan and it complains that

                  Unable to expand: xpathLessThan expr "xmldata/record/status", "1"[13,2]: unknown:13:2 Unexpected token 'xpathGreaterThan'[23,2]: unknown:23:2 Unexpected token 'xpathLessThan'
                  


                  It seems like it does not load the XPathLanguage.dsl

                  • 6. Re: Content Based Routing problem
                    beve

                    can you send me your .esb archive and I'll take a look?

                    • 7. Re: Content Based Routing problem

                      It looks like XPathLanguage.dsl will work only if the XML has namespaces defined and then you use the "use namespaces" expression.

                      xpathEquals expr "/order:Order/@statusCode", " " use namespaces "order=http://org.jboss.soa.esb/Order"
                      


                      How would I change the .dsl file to support XML without namespaces? like this:
                      xpathEquals expr "/Order/@statusCode", " "
                      


                      Looks like the namespace unaware methods don't work. Could you verify this on your side?

                      • 8. Re: Content Based Routing problem
                        beve

                        Hi,

                        When using xpath dsl without namespaces we needed the expressions to be different.
                        So the one without namespaces should be:

                        xpathEquals "/Order/OrderLines/OrderLine/Product/@productId", "1"
                        

                        and the one that uses namespaces:
                        xpathEquals expr "/order:Order/@statusCode", "2" use namespaces "order=http://org.jboss.soa.esb/Order"
                        

                        Notice that the namespace aware statements differ in that they need the extra 'expr' in front of the XPath expression. This is do avoid colliding with the non XPath aware statements in the dsl file.

                        This is mentioned in the "XPath Domain Specific Language" in the ServiceGuide.pdf but I had forgotten about it. Sorry about that.

                        Regards,

                        /Daniel

                        • 9. Re: Content Based Routing problem

                          Thank you. That did it! At least for the standard xpath methods included in the ESB.

                          One last question... if I have a newdsl.dsl file and I include it in my rules(.drl) like this

                          expander NewDsl.dsl
                          

                          what is the proper location for the .dsl file? inside of the jbossrules.esb?

                          I tried putting it inside of my .esb archive but I get a message:
                          Unexpected token 'xpathBoolean'
                          


                          inside my rule I have
                          xpathBoolean "xmldata/record/id = 12345"
                          


                          • 10. Re: Content Based Routing problem
                            beve

                            Yes, that is the correct location.

                            Did you update the dsl in jboss-esb.xml aswell:

                            <property name="ruleLanguage" value="NewDsl.dsl"/>





                            • 11. Re: Content Based Routing problem

                              I didn't realize that it needs to be included both in the .drl file and the jboss-esb.xml.

                              Thank you!