3 Replies Latest reply on Oct 2, 2007 11:06 AM by Haagen Hasle

    StaticRouter and Aggregator

    Haagen Hasle Novice

      Hi!

      I'm fairly new to JBoss ESB, and I need some help with routing and aggregating my messages. I hope someone here can help me.

      I'm trying to the following:
      I'm exposing a webservice that connects to the ESB. Inside the ESB, I route (split) the message to two different services. These services both return a Customer (I'm doing some transformations so that they both return the same class.) I'd like to use an Aggregator to "merge" these two Customers into one, but it appears the Aggregator is never called.

      My configuration looks like this (modified to be easier to read):
      ---

      <service category="CustomerCategory" name="CustomerSearch"
       description="..">
       <listeners>
       <jms-listener name="JMS-CustomerSearchListener" busidref="..."
       maxThreads="1" />
       </listeners>
       <actions>
       <action name="splitTheSearch"
       class="org.jboss.soa.esb.actions.StaticRouter" process="split">
       <property name="destinations">
       <route-to service-category="CustomerCategory"
       service-name="Customer1" />
       <route-to service-category="CustomerCategory"
       service-name="Customer2" />
       </property>
       </action>
       <action name="aggregateTheResults"
       class="org.jboss.soa.esb.actions.Aggregator">
       <property name="timeoutInMillies" value="60000" />
       </action>
       <action name="transformTwoCustomersToOne" class="..."
       process="...">
       </action>
       </actions>
      </service>
      
      <service category="CustomerCategory" name="Customer1"
       description="..">
       <listeners>
       <jms-listener name="JMS-Customer1Listener" busidref="..."
       maxThreads="1" />
       </listeners>
       <actions>
       <action name="transformBeforeFor" class="..." process="...">
       </action>
       <action name="doSomethingThatReturnsACustomer1" class="..." />
       <action name="transformAfter" class="..." process="..." />
       </actions>
      </service>
      
      <service category="CustomerCategory" name="Customer2"
       description="..">
       <listeners>
       <jms-listener name="JMS-Customer2Listener" busidref="..."
       maxThreads="1" />
       </listeners>
       <actions>
       <action name="transformBeforeFor" class="..." process="..." />
       <action name="doSomethingThatReturnsACustomer2" class="..." />
       <action name="transformAfter" class="..." process="..." />
       </actions>
      </service>



      ---
      The StaticRouter successfully routes the messages to the two different services, but the Aggregator is never used. What am I doing wrong?

      When I read about routing and aggregating in the documentation and the samples, it is a bit difficult to understand what to do. One place I read that process="splitt" is no longer necessary, but another place it says that this is what makes the Aggregator work.

      Best regards, Haagen

        • 1. Re: StaticRouter and Aggregator
          Jiri Pechanec Apprentice

          Hi, the problem is that you need to send messages from services Customer1 and Customer2 to service Aggregator. So you need to have the last action in both services to be something like

          <action name="routeToAggregator"
           class="org.jboss.soa.esb.actions.StaticRouter">
           <property name="destinations">
           <route-to service-category="CustomerCategory"
           service-name="Aggregator" />
           </property>
          

          And then you need to establish separate service Aggregator that will contain action Aggregator.
          <service category="CustomerCategory" name="Aggregator"
           description="Aggregates the previously splitted messages">
           <listeners>
           <jms-listener name="JMS-CustomerAggregatorListener" busidref="..."
           maxThreads="1" />
           </listeners>
           <actions>
           <action name="aggregateTheResults"
           class="org.jboss.soa.esb.actions.Aggregator">
           <property name="timeoutInMillies" value="60000" />
           </action>
           <action name="transformTwoCustomersToOne" class="..."
           process="...">
           </action>
           </actions>
          </service>
          


          • 2. Re: StaticRouter and Aggregator
            Haagen Hasle Novice

            Ok, great. Thanks for a fast reply!

            But can the outgoing-message from the Aggregator-service still work as the reply from the originating WebService (=the output from the CustomerSearch-service)? (I guess I'll find out soon enough, I'll try this out at once.. :-)

            And another question - how do I know the aggregator-tags to use when I transform the attachements the Aggregator puts on the Message into a "merged Customer"?


            Regards, Haagen

            • 3. Re: StaticRouter and Aggregator
              Haagen Hasle Novice


              I found out the aggregatorTags-thing by myself, by looking at the code for Aggregator and MessageRouter. And the reply to the WebService sorted itself out.

              I'm not sure if I need all the JMS-queues I've defined for the services I use, I've made two for each (one for the request and one for the reply), but I can find that out by trial-and-error.

              I kind of miss the vm-transport that Mule has, but I read somewhere that you (as in JBoss) are working on it. Keep up the good work, and again - thanks for the reply!