4 Replies Latest reply on Aug 12, 2008 1:44 AM by neha2911

    Problem in Content Based Routing

      I want to perform Content Based Routing. I want to give my custom object for the rules to execute the action.I am sending a serialized java object using jms .
      But i am unable to get the right output.

      My JBossesb.xml snippet is

      
       <services>
       <!-- ESB CBR Service -->
       <service category="MyFirstCBRServicesESB" description="ESB Listener" name="FirstCBRServiceESB">
       <listeners>
       <!-- Gateway -->
       <jms-listener busidref="quickstartGwChannel" is-gateway="true"
       maxThreads="1" name="the-gateway"/>
       <jms-listener busidref="quickstartEsbChannel" maxThreads="1" name="XPathContentBasedRouter"/>
       </listeners>
       <actions mep="OneWay">
       <action name="print" class="org.jboss.soa.esb.actions.SystemPrintln">
       <property name="message"
       value="Message beforeeee Routing"/>
       </action>
       <action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="ContentBasedRouter">
       <property name="destinations">
       <route-to destination-name="express"
       service-category="ExpressShipping" service-name="ExpressService"/>
       <route-to destination-name="normal"
       service-category="NormalShipping" service-name="NormalService"/>
       <route-to destination-name="test"
       service-category="Test" service-name="TestService"/>
       </property>
       <property name="ruleReload" value="true"/>
       <property name="ruleSet" value="SimpleCBRRules"/>
       <property name="object-paths">
       <object-path esb="body.Task" />
       </property>
      
       </action> </actions>
       </service>


      My Rule file 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;
      import task.Task;
      
      //expander XPathLanguage.dsl
      
      #declare any global variables here
      global java.util.List destinations;
      
      rule "Routing Rule using XPATH"
      
       when
       t : Task(status == 1)
      
       then
       System.out.println("EXPRESS");
       destinations.add("express");
      
      
      end
      
      rule "Routing Rule using XPATH less"
       when
       t:Task(status == 2 )
      
       then
      
       System.out.println("NORMAL");
       destinations.add("normal");
      
      end
      
      rule "Routing Rule using XPATH test"
       when
       t:Task(status == 3)
      
       then
       System.out.println("TEST");
       destinations.add("test");
      
      end
      


      Iam sending a Task object with the status member defined to the queue but iam not able to find the desired output.

      How to go about it ?


        • 1. Re: Problem in Content Based Routing
          beve

          Hi,

          try printing the whole message structure by adding the property "printfull" and setting it to "true" on the SystemPrintln action.
          This will show the location of the Task object in the message. By the look of this:

          <object-path esb="body.Task" />

          you are expecting it to be bound under the location 'Task'.

          One quickstart that might help you out is the business_rules_service quickstart.

          Regards,

          /Daniel

          • 2. Re: Problem in Content Based Routing

            hi beve,

            Thankyou for the reply.

            I receive the following error when i execute the code .

            2008-08-11 15:51:52,216 INFO [org.quartz.core.QuartzScheduler] Scheduler DefaultQuartzScheduler_$_NON_CLUSTERED started.
            2008-08-11 15:52:13,700 INFO [STDOUT] Message structure:
            2008-08-11 15:52:13,700 INFO [STDOUT] [ message: [ JBOSS_XML ]
            header: [ To: JMSEpr [ PortReference < <wsa:Address jms://localhost/queue/B/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.initial : org.jnp.interfaces.NamingContextFactory/>, <wsa:ReferenceProperties jbossesb:java.naming.provider.url : localhost/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.url.pkgs : org.jnp.interfaces/>, <wsa:ReferenceProperties jbossesb:destination-type : queue/>, <wsa:ReferenceProperties jbossesb:specification-version : 1.1/>, <wsa:ReferenceProperties jbossesb:connection-factory : ConnectionFactory/>, <wsa:ReferenceProperties jbossesb:persistent : true/>, <wsa:ReferenceProperties jbossesb:acknowledge-mode : AUTO_ACKNOWLEDGE/>, <wsa:ReferenceProperties jbossesb:transacted : false/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/jms/> > ] MessageID: ID:JBM-262656 RelatesTo: jms:correlationID#ID:JBM-262144 ]
            context: [ ]
            body: [ objects: {org.jboss.soa.esb.message.defaultEntry=task.Task@1b3a9cd, org.jboss.soa.esb.message.defaultEntry-set-stack=Deferred serialized value: 50e304} ]
            fault: [ ]
            attachments: [ Named:{}, Unnamed:[] ]
            properties: [ {org.jboss.soa.esb.message.time.dod=Mon Aug 11 15:52:13 IST 2008, org.jboss.soa.esb.message.time.dob=Deferred serialized value: 68291b, org.jboss.soa.esb.message.source=Deferred serialized value: 62c67e, jbesbfilename=SimpleCBRTest.log, org.jboss.soa.esb.message.transport.type=Deferred serialized value: d58bd5, javax.jms.message.redelivered=false, org.jboss.soa.esb.gateway.original.queue.name=Deferred serialized value: 1cf4e67} ] ]
            2008-08-11 15:52:13,700 WARN [org.jboss.soa.esb.message.mapping.ObjectMapper] The value of body.Task is null
            2008-08-11 15:52:31,872 ERROR [org.jboss.soa.esb.actions.ContentBasedWiretap] No rule destination(s) [normal, express, test] were matched, . Please fix your configuration and/or routing rules.
            2008-08-11 15:52:41,278 WARN [org.jboss.soa.esb.listeners.message.ActionProcessingPipeline] Unexpected exception caught while processing the action pipeline: header: [ To: JMSEpr [ PortReference < <wsa:Address jms://localhost/queue/B/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.initial : org.jnp.interfaces.NamingContextFactory/>, <wsa:ReferenceProperties jbossesb:java.naming.provider.url : localhost/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.url.pkgs : org.jnp.interfaces/>, <wsa:ReferenceProperties jbossesb:destination-type : queue/>, <wsa:ReferenceProperties jbossesb:specification-version : 1.1/>, <wsa:ReferenceProperties jbossesb:connection-factory : ConnectionFactory/>, <wsa:ReferenceProperties jbossesb:persistent : true/>, <wsa:ReferenceProperties jbossesb:acknowledge-mode : AUTO_ACKNOWLEDGE/>, <wsa:ReferenceProperties jbossesb:transacted : false/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/jms/> > ] MessageID: ID:JBM-262656 RelatesTo: jms:correlationID#ID:JBM-262144 ]
            org.jboss.soa.esb.actions.ActionProcessingException: No rule destination(s) [normal, express, test] were matched, . Please fix your configuration and/or routing rules.
             at org.jboss.soa.esb.actions.ContentBasedWiretap.process(ContentBasedWiretap.java:106)
             at org.jboss.soa.esb.actions.ContentBasedRouter.process(ContentBasedRouter.java:52)
             at org.jboss.soa.esb.listeners.message.ActionProcessingPipeline.process(ActionProcessingPipeline.java:316)
             at org.jboss.soa.esb.listeners.message.MessageAwareListener$TransactionalRunner.run(MessageAwareListener.java:530)
             at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
             at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
             at java.lang.Thread.run(Thread.java:595)
            2008-08-11 15:52:41,294 WARN [org.jboss.soa.esb.listeners.message.ActionProcessingPipeline] No fault address defined for fault message! To: JMSEpr [ PortReference < <wsa:Address jms://localhost/queue/B/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.initial : org.jnp.interfaces.NamingContextFactory/>, <wsa:ReferenceProperties jbossesb:java.naming.provider.url : localhost/>, <wsa:ReferenceProperties jbossesb:java.naming.factory.url.pkgs : org.jnp.interfaces/>, <wsa:ReferenceProperties jbossesb:destination-type : queue/>, <wsa:ReferenceProperties jbossesb:specification-version : 1.1/>, <wsa:ReferenceProperties jbossesb:connection-factory : ConnectionFactory/>, <wsa:ReferenceProperties jbossesb:persistent : true/>, <wsa:ReferenceProperties jbossesb:acknowledge-mode : AUTO_ACKNOWLEDGE/>, <wsa:ReferenceProperties jbossesb:transacted : false/>, <wsa:ReferenceProperties jbossesb:type : urn:jboss/esb/epr/type/jms/> > ] MessageID: ID:JBM-262656 RelatesTo: jms:correlationID#ID:JBM-262144
            


            I am sending Task object with status =1 .
            In body the object is there but still the error comes that body.Task is null.

            • 3. Re: Problem in Content Based Routing
              beve

               

              2008-08-11 15:52:13,700 WARN [org.jboss.soa.esb.message.mapping.ObjectMapper] The value of body.Task is null

              You are getting this error because the Task object in not located in the location named Task. The task object instance is located as the default entry:
              objects: {org.jboss.soa.esb.message.defaultEntry=task.Task


              Try adding a action that puts the Task object in the correct location:
              message.getBody().add("Task",message.getBody().get());



              Regards,

              /Daniel


              • 4. Re: Problem in Content Based Routing

                Hi,
                Thanks it worked.
                But i have a little question , If i want to use the default entry in the body means i dont want to write any other action to place the object what should i do? Is it possible to use the custom object for content based routing without binding it to specific place or name?