8 Replies Latest reply on Nov 19, 2008 4:28 AM by Kevin Conner

    Router problem

    Vishal Novice

      Following is the ESB conf file i have a queue called nt_messageRouter on which an object is sent this object implements serializable interface and based on contents it is to be routed appropriately
      problem is when the object is sent to JMS queue called nt_messageRouter
      server gives following error

      14:21:34,117 ERROR [JmsComposer] Object in JMS message is not a org.jboss.soa.esb.message.Message
      java.lang.ClassCastException: com.nativetung.frontendServer.FESMessage cannot be cast to java.lang.String
       at org.jboss.soa.esb.util.Util.deserialize(Util.java:211)
       at org.jboss.internal.soa.esb.couriers.helpers.JmsComposer.compose(JmsComposer.java:72)
       at org.jboss.internal.soa.esb.couriers.JmsCourier.pickup(JmsCourier.java:404)
       at org.jboss.internal.soa.esb.couriers.TwoWayCourierImpl.pickup(TwoWayCourierImpl.java:232)
       at org.jboss.internal.soa.esb.couriers.TwoWayCourierImpl.pickup(TwoWayCourierImpl.java:214)
       at org.jboss.soa.esb.listeners.message.MessageAwareListener.waitForEventAndProcess(MessageAwareListener.java:280)
       at org.jboss.soa.esb.listeners.message.MessageAwareListener.doRun(MessageAwareListener.java:248)
       at org.jboss.soa.esb.listeners.lifecycle.AbstractThreadedManagedLifecycle.run(AbstractThreadedManagedLifecycle.java:115)
       at java.lang.Thread.run(Unknown Source)
      



      attached is the esb file
      can you tell me why this doesnt work ? on the other hand the messagefilter quickstart works much in same way

      thanks


      <?xml version = "1.0" encoding = "UTF-8"?>
      <jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">
      
       <providers>
       <jms-provider name="JBossMQ" connection-factory="ConnectionFactory"
       jndi-URL="jnp://127.0.0.1:1099" jndi-context-factory="org.jnp.interfaces.NamingContextFactory"
       jndi-pkg-prefix="org.jboss.naming:org.jnp.interfaces">
      
       <jms-bus busid="quickstartGwChannel">
       <jms-message-filter
       dest-type="QUEUE"
       dest-name="queue/nt_gw"
       />
       </jms-bus>
      
       <jms-bus busid="quickstartEsbChannel">
       <jms-message-filter
       dest-type="QUEUE"
       dest-name="queue/nt_esb"
       />
       </jms-bus>
       <jms-bus busid="TSQueue">
       <jms-message-filter
       dest-type="QUEUE"
       dest-name="queue/nt_ts"
       />
       </jms-bus>
       <jms-bus busid="TSEsb">
       <jms-message-filter
       dest-type="QUEUE"
       dest-name="queue/nt_tsesb"
       />
       </jms-bus>
       <jms-bus busid="TManager">
       <jms-message-filter
       dest-type="QUEUE"
       dest-name="queue/nt_tmanager"
       />
       </jms-bus>
       <jms-bus busid="CManager">
       <jms-message-filter
       dest-type="QUEUE"
       dest-name="queue/nt_cmanager"
       />
       </jms-bus>
       <jms-bus busid="MessageStore">
       <jms-message-filter
       dest-type="QUEUE"
       dest-name="queue/nt_messageStore"
       />
       </jms-bus>
       <jms-bus busid="MessageRouter">
       <jms-message-filter
       dest-type="QUEUE"
       dest-name="queue/nt_messageRouter"
       />
       </jms-bus>
       <jms-bus busid="GoogleService">
       <jms-message-filter
       dest-type="QUEUE"
       dest-name="queue/nt_googleDest"
       />
       </jms-bus>
       </jms-provider>
       </providers>
      
       <services>
       <service
       category="FirstEclipseServiceESB"
       name="SimpleListener"
       description="Hello World">
       <listeners>
       <jms-listener name="JMS-Gateway"
       busidref="quickstartGwChannel"
       maxThreads="1"
       is-gateway="true"
       />
      
       <jms-listener name="helloWorld"
       busidref="quickstartEsbChannel"
       maxThreads="1"
       />
      
       </listeners>
       <actions>
       <!-- <action name="action1"
       class="com.nativetung.soa.esb.actions.MessageParserAction"
       process="processMessage"
       /> -->
       <action name="transformtopojo" class="org.jboss.soa.esb.actions.converters.SmooksTransformer" >
       <property name="resource-config" value="/smooks-res.xml" />
       <property name="java-output-location" value="$default" />
       </action>
       <action name="MessageGenerator" class="com.nativetung.soa.esb.actions.MsgGeneratorAction" process="processMessage"/>
      
       </actions>
       </service>
       <service
       category="TSService"
       name="TsListener"
       description="Translation Server">
       <listeners>
       <jms-listener name="JMS-Gateway"
       busidref="TSQueue"
       maxThreads="1"
       is-gateway="true"
       />
       <!-- <jms-listener name="helloWorld"
       busidref="quickstartEsbChannel"
       maxThreads="1"
       /> -->
       <jms-listener name="TS-ESB"
       busidref="TSEsb"
       maxThreads="1"
       />
      
      
       </listeners>
       <actions mep="OneWay">
       <action class="org.jboss.soa.esb.actions.ContentBasedRouter" name="ContentBasedRouter">
       <property name="ruleSet" value="FunCBRRules-XPath.drl"/>
       <property name="ruleLanguage" value="XPathLanguage.dsl"/>
       <property name="ruleReload" value="true"/>
       <property name="destinations">
       <route-to destination-name="TM" service-category="TMService" service-name="TmListener" />
       <route-to destination-name="CM" service-category="CMService" service-name="CmListener" />
       </property>
       </action>
       </actions>
       </service>
      
       <!-- Translation manager service -->
       <service
       category="TMService"
       name="TmListener"
       description="Translation Manager">
       <listeners>
       <jms-listener name="TManagerListener"
       busidref="TManager"
       maxThreads="1"
       />
       </listeners>
       <actions mep="OneWay">
       <action name="Translate Action"
       class="com.nativetung.soa.esb.actions.TMAction"
       process="processMessage"
       />
       <action name="transformtopojo" class="org.jboss.soa.esb.actions.converters.SmooksTransformer" >
       <property name="resource-config" value="/smooks-res.xml" />
       <property name="java-output-location" value="$default" />
       </action>
       <action name="convertPOJO2Message" class="com.nativetung.soa.esb.actions.TMPojoToMessage" />
      
      
      
       </actions>
       </service>
      
       <!-- Capitalization manager service -->
       <service
       category="CMService"
       name="CmListener"
       description="Capitalization Manager">
       <listeners>
       <jms-listener name="CManagerListener"
       busidref="CManager"
       maxThreads="1"
       />
       </listeners>
       <actions mep="OneWay">
       <action name="Capatalization Action"
       class="com.nativetung.soa.esb.actions.CMAction"
       process="processMessage"
       />
       <action name="transformtopojo" class="org.jboss.soa.esb.actions.converters.SmooksTransformer" >
       <property name="resource-config" value="/smooks-res.xml" />
       <property name="java-output-location" value="$default" />
       </action>
       <action name="convertPOJO2Message" class="com.nativetung.soa.esb.actions.TMPojoToMessage" />
       </actions>
      
       </service>
       <!-- agreegator service -->
       <service
       category="MessageStoreService"
       name="MsListener"
       description="MessageStore for messages">
       <listeners>
       <jms-listener name="MessageStoreListener"
       busidref="MessageStore"
       maxThreads="1"
       />
       </listeners>
       <actions mep="OneWay">
       <action name="transformtopojo" class="org.jboss.soa.esb.actions.converters.SmooksTransformer" >
       <property name="resource-config" value="/smooks-res.xml" />
       <property name="java-output-location" value="$default" />
       </action>
       <action name="MessageStore Action"
       class="com.nativetung.soa.esb.actions.MessageStoreAction"
       process="processMessage"
       />
       </actions>
       </service>
       <service
       category="MessageRouterService"
       name="RouterListener"
       description="MessageRouter for messages">
       <listeners>
       <jms-listener name="RouterListener"
       busidref="MessageRouter"
       maxThreads="1"
       />
       </listeners>
       <actions mep="OneWay">
       <action class="org.jboss.soa.esb.actions.MessageFilter" name="MessageFilter">
       <property name="ruleSet" value="FilterRules.drl"/>
       <property name="ruleReload" value="true"/>
       <property name="destinations">
       <route-to destination-name="googleDestination" service-category="GoogleGatewyService" service-name="GoogleListener"/>
       </property>
       <property name="object-paths">
       <object-path esb="body.'org.jboss.soa.esb.message.defaultEntry'" />
       </property>
       </action>
       </actions>
      
       </service>
       <service
       category="GoogleGatewayService"
       name="GoogleListener"
       description="Google Service for message tranaslation">
       <listeners>
       <jms-listener name="GoogleListener"
       busidref="GoogleService"
       maxThreads="1"
       />
       </listeners>
       <actions mep="OneWay">
       <action name="Google Service Action"
       class="com.nativetung.soa.esb.actions.MessageRouterService"
       process="processMessage"
       />
       </actions>
      
       </service>
       </services>
      
      </jbossesb>
      


        • 1. Re: Router problem
          Daniel Bevenius Master

          Hi,

          The "RouterListener" listener is a esb-aware listener and expects the content of the JMS Message to be an ESB Message object.
          Where is the routing performed? Is this done by 'com.nativetung.soa.esb.actions.MessageRouterService" action ?

          Regards,

          /Daniel

          • 2. Re: Router problem
            Vishal Novice

            later on i also added the esb queue with JMS and now i m sending ESB message instead of JMS

             <service
             category="MessageRouterService"
             name="RouterListener"
             description="MessageRouter for messages">
             <listeners>
             <jms-listener name="RouterListener"
             busidref="MessageRouter"
             maxThreads="1"
             />
             <jms-listener name="RouterListener_esb"
             busidref="MessageRouter_esb"
             maxThreads="1"
             />
             </listeners>
             <actions mep="OneWay">
             <action class="org.jboss.soa.esb.actions.MessageFilter" name="MessageFilter">
             <property name="ruleSet" value="FilterRules.drl"/>
             <property name="ruleReload" value="true"/>
             <property name="destinations">
             <route-to destination-name="googleDestination" service-category="GoogleGatewyService" service-name="GoogleListener"/>
             </property>
             <property name="object-paths">
             <object-path esb="body.'org.jboss.soa.esb.message.defaultEntry'" />
             </property>
             </action>
             </actions>
            
             </service>
            


            I m sending an object which is serializable and having a field called messageType my drools file looks like this
            #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.format.MessageType;
            import org.jboss.soa.esb.samples.quickstart.helloWorld.FESMessage
            
            #declare any global variables here
            global java.util.List destinations;
            
            rule "Pricing Rule - over threshold"
             System.out.println("checking rule");
            
             when
             m:message()
             f: FESMessage(messageType="google")
            
             then
             System.out.println("Type is google");
             destinations.add("googleDestination");
            end
            
            rule "Pricing Rule - under threshold"
            
             #adding this for debug output, the important part is to *NOT* set a destination
             when
            
             then
            
            end
            


            i think routing is to be performed by MEssageFilter class from ESB isnt it ?

            • 3. Re: Router problem
              Daniel Bevenius Master

              Can you send me this in an example and I'll take a look.

              Thanks,

              /Daniel

              • 4. Re: Router problem
                Vishal Novice

                i will try but can you suggest something to try by the time ?

                • 5. Re: Router problem
                  Daniel Bevenius Master

                   

                  problem is when the object is sent to JMS queue called nt_messageRouter

                  This queue is declared here:
                  <jms-bus busid="MessageRouter">
                   <jms-message-filter
                   dest-type="QUEUE"
                   dest-name="queue/nt_messageRouter"
                   />
                   </jms-bus>
                  

                  And configured for this service:
                  <service
                   category="MessageRouterService"
                   name="RouterListener"
                   description="MessageRouter for messages">
                   <listeners>
                   <jms-listener name="RouterListener"
                   busidref="MessageRouter"
                   maxThreads="1"
                   />
                   </listeners>
                  

                  So, if the first statement is true then the error you are getting is when something is calling this service. This would happen before the message can be delivered to the action pipeline.

                  This part of the rules file does not look valid to me:
                  rule "Pricing Rule - over threshold"
                   System.out.println("checking rule");
                  
                   when
                   m:message()
                   f: FESMessage(messageType="google")
                  
                   then
                   System.out.println("Type is google");
                   destinations.add("googleDestination");
                  end
                  

                  I would think that if the pipeline was being invoked you would see an error message about it.

                  Regards,

                  /Daniel


                  • 6. Re: Router problem
                    Vishal Novice

                    my question is here when the message will be send to the JMS queue it will reach to the message filter class so i thnk should it recognize the Serializable object ? What have done is basically just mimic the messagefilter example here , also i already mentioned that i also tried using ESB but in that case there was no activity on console , not even an error

                    • 7. Re: Router problem
                      Daniel Bevenius Master

                      Sorry, I can't do much more then look at the information that you have provided and try to figure out what is going on.

                      As I said, if you supply an example, perhaps by modifying the messagefilter quickstart, that reproduces this issue I'd be happy to take a look at it.

                      Regards,

                      /Daniel

                      • 8. Re: Router problem
                        Kevin Conner Master

                        The problem, as Daniel has already pointed out, is that you are sending a non-ESB message to an ESB aware endpoint.

                        If you wish to send raw JMS messages into this ESB service then you must do this through a gateway queue so, in the case of your MessageRouter it should be configured as follows

                        <jms-listener name="RouterListener"
                         busidref="MessageRouter"
                         maxThreads="1"
                         is-gateway="true"
                        />

                        If, on the other hand, you are intending to send ESB messages then you should be using ServiceInvoker.