7 Replies Latest reply on Sep 20, 2007 10:58 AM by kconner

    need explanation about quickstart helloworld flow of events

      I would like to have some explanation about the helloworld quickstart.
      there are two jms bus that are defined here:



      <jms-bus busid="quickstartGwChannel">
      <jms-message-filter
      dest-type="QUEUE"
      dest-name="queue/helloworld_Request_gw"
      />
      </jms-bus>
      <jms-bus busid="quickstartEsbChannel">
      <jms-message-filter
      dest-type="QUEUE"
      dest-name="queue/helloworld_Request_esb"
      />
      </jms-bus>


      There are two listeners that are listening to the queues below:


      <listeners>
      <jms-listener name="JMSGatewayListener" busidref="quickstartGwChannel" maxThreads="1" is-gateway="true"/>
      <jms-listener name="helloWorldListener" busidref="quickstartEsbChannel" maxThreads="1"/>
      </listeners>
      <actions>
      <action name="helloAction"
      class="com.natixis.sample.esb.helloworld.JMSListenerAction"
      process="displayMessage"
      />


      </actions>


      The JMSGatewayListener listen to the quickstartGwChannel queue.
      The helloWorldListener listen to the quickstartEsbChannel.
      When a JMS message is sent to the quickstartGwChannel queue, the JMSGatewayListener take the message and transforms it.
      But I'm troubleshooted about the way the message is forwarded to the quickstartEsbChannel queue by the JMSGatewayListener.
      Can someone explains me how this can take place?

      thank in advance.
      Meissa

        • 1. Re: need explanation about quickstart helloworld flow of eve

          Hello, look at the xml schema
          http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd

          There is written that service has (ONE) listener or gateways and a list of actions. So gateway knows the listener because it's the only one written in the configuration. So gateway asks registry for (FirstServiceESB, SimpleListener), and gets the name of the queue where the listener listens.

          • 2. Re: need explanation about quickstart helloworld flow of eve

             

            "kadlecp" wrote:
            Hello, look at the xml schema
            http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd

            There is written that service has (ONE) listener or gateways and a list of actions. So gateway knows the listener because it's the only one written in the configuration. So gateway asks registry for (FirstServiceESB, SimpleListener), and gets the name of the queue where the listener listens.


            thank you for you reply.
            Things are easy for me by now.

            Meissa

            • 3. Re: need explanation about quickstart helloworld flow of eve

              I have beem examining source code and I was wrong. There can be more then one listener. But only one listener will be used by gateway for a delivery of the message. The one listener will be determined by LoadBalancePolicy, which is implemented by FirstAvailable by default. You can make your own LoadBalancer. I hope I right now:-) Look at source code of LoadBalancePolicy, FirstAvailable and RoundRobin for more information....

              • 4. Re: quickstart helloworld flow of events/selecting the right

                I have inspected the code of the FirstAvailable Class, the stuff is in the chooseEPR method below.

                 public EPR chooseEPR (ServiceClusterInfo serviceCluster)
                 {
                 List<EPR> eprs = serviceCluster.getEPRs ();
                 if (eprs.size () == 0)
                 return null;
                
                 if ( (this.electedEPR != null) && eprs.contains (this.electedEPR) ){
                 return this.electedEPR;
                 } else {
                 int cursor = RandomRobin.localRandomizer.nextInt(eprs.size());
                 this.electedEPR = eprs.get(cursor);
                 return this.electedEPR;
                 }
                 }
                


                That shows that if we have only one listener, it will always work. But if we have more than one, nothing guarantees that we'll always have the same (if we wanted it) that will be choosen, unless we do something special (writting our own LoadBalacer as you suggested it).
                Maybe is it possible to explicity decide it at config time.
                Meissa

                • 5. Re: need explanation about quickstart helloworld flow of eve
                  kconner

                  A few comments which will (hopefully) clarify things

                  The LoadBalancePolicy is only supported for stateless services and, as such, it shouldn't matter (from a functional perspective) which EPR is chosen for the request. The policy in place should be based upon how you wish the load to be distributed.

                  When Kurt added this code he created three policies

                  FirstAvailable
                  RoundRobin
                  RandomRobin

                  FirstAvailable chooses an EPR at random from the list of EPRs associated with the service. Subsequent requests will continue to be sent to the chosen EPR provided that the same ServiceInvoker instance is used and that the EPR remains in the set of EPRs associated with the service. If a different ServiceInvoker instance is used, or if the EPR is removed from the set, then another EPR will be chosen at random.

                  RoundRobin sends invocations in sequence to the EPRs associated with the service, starting at a random point. Again, the same ServiceInvoker instance should be used.

                  RandomRobin will always choose an EPR at random.

                  Does this help?

                  • 6. Re: need explanation about quickstart helloworld flow of eve

                    Thank you for clarifying things.
                    I have two questions:
                    1)What do you mean by "stateless service" ?
                    2)In the case of the helloworld (as in the case of all services alike)

                    The JMSGatewayListener listen to the quickstartGwChannel queue.
                    The helloWorldListener listen to the quickstartEsbChannel.
                    When a JMS message is sent to the quickstartGwChannel queue, the JMSGatewayListener take the message and transforms it.
                    But I'm troubleshooted about the way the message is forwarded to the quickstartEsbChannel queue by the JMSGatewayListener.

                    Why does the JMSGatewayListener sends the message to the queue( quickstartEsbChannel) where the helloworld is listening.

                    Meissa

                    • 7. Re: need explanation about quickstart helloworld flow of eve
                      kconner

                       

                      "meissa" wrote:
                      1)What do you mean by "stateless service" ?


                      A stateless service is one which does not keep state between the processing of each message. The processing of a message would only be reliant on the contents of the message and a global (persistent) state.

                      "meissa" wrote:
                      Why does the JMSGatewayListener sends the message to the queue( quickstartEsbChannel) where the helloworld is listening.

                      The helloworld service is a standard ESB service and, as such, can process messages from multiple sources. The JMS gateway is one possible source but the service can (just as easily) receive messages from other gateways/services.