0 Replies Latest reply on Jun 4, 2008 11:17 AM by lisa.winkler

    ContentBasedRouter not evaluating rules against object-paths

    lisa.winkler

      Hello,

      I am working with the ContentBasedRouter action (org.jboss.soa.esb.actions.ContentBasedRouter), using JBoss ESB 4.2.1 GA as included with JBoss SOA platform 4.2. I've read and followed the examples in the ContentBasedRouting.pdf, and also found this thread quite helpful: http://www.jboss.com/index.html?module=bb&op=viewtopic&t=109514&postdays=0&postorder=asc&start=0

      My ESB messages contain a Java object (MyObject) which is inserted into the message body at the named location "MyObject". This object has a property that is a String containing XML metadata. So, I would like to use the XPath routing rules (XPathLanguage.dsl) to match against myObject.getMetadata().

      I've configured my action as follows:

      <action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="ContentBasedRouter">
       <property name="ruleSet" value="SDERules-XPath.drl"/>
       <property name="ruleLanguage" value="XPathLanguage.dsl"/>
       <property name="ruleReload" value="true"/>
       <property name="destinations">
       <route-to destination-name="test1" service-category="SDE" service-name="SDETest1Service"/>
       <route-to destination-name="test2" service-category="SDE" service-name="SDETest2Service"/>
       </property>
       <property name="object-paths">
       <object-path esb="body.MyObject.Metadata"/>
       </property>
      </action>
      


      And here is the relevant portion my SDERules-XPath.drl (omitted imports, etc):
      rule "Routing Rule using XPATH Version=1.0"
       when
       xpathEquals "/platform_metadata/version", "1.0"
       then
       Log : "Matched rule 1.0";
       Destination : "test1";
      end
      
      rule "Routing Rule using XPATH Version=2.0"
       when
       xpathEquals "/platform_metadata/version", "2.0"
       then
       Log : "Matched rule 2.0";
       Destination : "test2";
      end
      


      After some debugging I have verified that the JBossRulesRouter is correctly evaluating my object-path and inserting my metadata into working memory, in addition to the message itself. It then fires the Drools engine which should run my rules against each item in the working memory.

       if (objectList!=null) {
       for (Object object : objectList) {
       workingMemory.insert(object);
       }
       }
       workingMemory.insert(message);
       logger.log(Level.DEBUG, "Fire the JBossRules Engine");
       workingMemory.fireAllRules();
      


      The metadata is well-formed XML and should match one of these rules. However, when JBossRulesRouter fires the rules, it appears to only attempt to match the rules against the message, ignoring the metadata. Of course, the message itself does not match my rules because it is not an XML String. So, ContentBasedRouter finds no destinations and drops my message on the Dead Letter Service.

      I'm inexperienced with Drools DSL, but in looking at the XPathLanguage.dsl I see that each rule references org.jboss.soa.esb.message.Message. To me this implies that the rule will in fact only attempt to match against something that is a Message. This is consistent with my findings above. But, it seems to imply that you can only use the XPathLanguage.dsl if your message contains an XML string in the body.

      So, my question is:
      Is it possible to use the XPathLanguage.dsl with the object-paths feature of the ContentBasedRouter? If so, can someone help me understand what I'm doing wrong?