1 2 3 4 Previous Next 46 Replies Latest reply on Jun 22, 2007 3:26 AM by marklittle

    Problems with delivering the request message sysnchronously

    andre1001


      I was trying out JBoss 4.2 GA + ESB MR2 with a client calling one hundred times the server.

      I've notice that when the server is shut down in the middle of the process it remains one message on my reply queue. When I start again the server, the client gets this message for the first request causing a shift in the remainders responses. Like this...

      request 1 -> gets response from last execution
      request 2 -> gets response 1
      request 3 -> gets response 2
      and so on.

      What would be the best solution? Am I doing something wrong?

      Thanks.

      My code (based on webservice example):

      
      
      //For setting up the basic WS
      import javax.jws.WebMethod;
      import javax.jws.WebService;
      import javax.jws.soap.SOAPBinding;
      import javax.xml.registry.RegistryException;
      
      //For ESB Interaction
      import org.jboss.soa.esb.message.Message; // jbossesb-rosetta.jar
      import org.jboss.soa.esb.message.format.MessageFactory; // jbossesb-rosetta.jar
      import org.jboss.soa.esb.message.format.MessageType; // jbossesb-rosetta.jar
      import org.jboss.soa.esb.listeners.message.MessageDeliveryAdapter; // jbossesb-rosetta.jar
      
      @WebService(name = "Endereco", targetNamespace = "http://webservice/endereco")
      @SOAPBinding(style = SOAPBinding.Style.RPC)
      public class EnderecoWS {
      
       @WebMethod
       public EnderecoBean getEndereco(EnderecoBean e){
      
       System.out.println("*** Endereco Recebido WS ***");
       System.out.println("ws recebido id: "+e.getId());
       System.out.println("ws recebido name: "+e.getName());
      
       EnderecoBean resp = null;
       try {
       // Cachear delivery adapter para o servico
       MessageDeliveryAdapter deliveryAdapter = new MessageDeliveryAdapter("CategoriaEndereco", "ServicoEndereco");
       // Cachear o factory de mensagens
       MessageFactory mfactory = MessageFactory.getInstance();
      
       Message requestMessage;
       Message replyMessage = null;
      
       // Create and populate the request message...
       requestMessage = mfactory.getMessage(MessageType.JAVA_SERIALIZED);
      
       requestMessage.getBody().add(e);
      
      
       // Deliver the request message synchronously - timeout after 5 seconds...
       replyMessage = deliveryAdapter.deliverSync(requestMessage, 5000);
      
       resp = (EnderecoBean)replyMessage.getBody().get();
      
       if (resp!=null){
       // Logar endereco enviado
       System.out.println("*** Endereco Enviado WS ***");
       System.out.println("ws enviado id: "+resp.getId());
       System.out.println("ws enviado name: "+resp.getName());
       }
       } catch (Exception ex) {
       ex.printStackTrace();
       }
       return resp;
      
       }
      }
      
      


        • 1. Re: Problems with delivering the request message sysnchronou
          burrsutter

          Can you provide a testcase that illustrates the issue?

          What kind of transports does this service "CategoriaEndereco":"ServicoEndereco" use? JMS?

          • 2. Re: Problems with delivering the request message sysnchronou
            andre1001

            Hi Burr,

            we've made a multithreaded test using ESB 4.2MR2 deployed into JBoss AS 4.2.0 GA based on ESB webservice_war1 sample.

            These are my client classes:

            public class TesteHello {
            
             public static void main(String[] args) throws Exception{
            
             ThreadHello t1 = new ThreadHello();
             ThreadHello t2 = new ThreadHello();
             ThreadHello t3 = new ThreadHello();
             ThreadHello t4 = new ThreadHello();
             ThreadHello t5 = new ThreadHello();
             ThreadHello t6 = new ThreadHello();
             ThreadHello t7 = new ThreadHello();
             ThreadHello t8 = new ThreadHello();
             ThreadHello t9 = new ThreadHello();
             ThreadHello t10 = new ThreadHello();
            
             t1.start();
             t2.start();
             t3.start();
             t4.start();
             t5.start();
             t6.start();
             t7.start();
             t8.start();
             t9.start();
             t10.start();
             }
            
            }
            


            import java.text.SimpleDateFormat;
            import java.util.Date;
            
            import webservice_war1.helloworld.HelloWorld;
            import webservice_war1.helloworld.HelloWorldService;
            
            public class ThreadHello extends Thread {
            
             public void run() {
            
             HelloWorld h = new HelloWorldService().getHelloWorldPort();
             SimpleDateFormat simpleDateFormat=new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS");
            
             // Get ID Thread
             long id_thread = this.getId();
            
             for (int i = 0; i < 10; i++) {
             Date d = new Date();
             String wsin = "thread:" +id_thread + " date:" + simpleDateFormat.format(d);
             String wsout = h.sayHello(wsin);
             System.out.println("IN > " + wsin + " | OUT > " + wsout);
             }
             }
            
            }
            
            



            First problem


            The expected answer should have had the same thread numbers and times, like this:

            IN > thread:12 date:23/05/2007 11:56:47.515 | OUT > Hello From ESB MyAction: thread:12 date:23/05/2007 11:56:47.515

            But I've got these ones:

            IN > thread:11 date:23/05/2007 11:56:47.546 | OUT > Hello From ESB MyAction: thread:9 date:23/05/2007 11:56:47.500
            IN > thread:13 date:23/05/2007 11:56:47.484 | OUT > Hello From ESB MyAction: thread:11 date:23/05/2007 11:56:47.546
            IN > thread:15 date:23/05/2007 11:56:47.500 | OUT > Hello From ESB MyAction: thread:7 date:23/05/2007 11:56:47.500
            IN > thread:16 date:23/05/2007 11:56:47.500 | OUT > Hello From ESB MyAction: thread:14 date:23/05/2007 11:56:47.500
            IN > thread:14 date:23/05/2007 11:56:47.500 | OUT > Hello From ESB MyAction: thread:8 date:23/05/2007 11:56:47.500
            IN > thread:7 date:23/05/2007 11:56:47.500 | OUT > Hello From ESB MyAction: thread:16 date:23/05/2007 11:56:47.500
            IN > thread:9 date:23/05/2007 11:56:47.500 | OUT > Hello From ESB MyAction: thread:15 date:23/05/2007 11:56:47.500
            IN > thread:8 date:23/05/2007 11:56:47.500 | OUT > Hello From ESB MyAction: thread:13 date:23/05/2007 11:56:47.484
            IN > thread:10 date:23/05/2007 11:56:47.500 | OUT > Hello From ESB MyAction: thread:10 date:23/05/2007 11:56:47.500

            What would I do to solve this issue and get the right answer?


            Second problem

            Besides, I've notice that for some reason when my ConnectionPool is exceeded (or when I shut down the server), some reply messages are kept on JMS_MESSAGES table.

            Inside the log file we can see:

            2007-05-23 13:07:09,078 DEBUG [org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool] Returning session, poolsize=20, maxsize=20, number of pools=2
            2007-05-23 13:07:09,078 DEBUG [org.jboss.mq.referenceable.SpyDestinationObjectFactory] SpyDestinationObjectFactory->getObjectInstance()
            2007-05-23 13:07:09,093 INFO [org.jboss.internal.soa.esb.rosetta.pooling.JmsConnectionPool] The connection pool was exhausted. Waiting 1 second before trying again..

            Is there any way to clean these messages or to prevent ESB from put them in the queue?



            I've sent you an e-mail with my Eclipse project. (Excuse me if it's too big. My client libs were included :) )

            Thanks.

            • 3. Re: Problems with delivering the request message sysnchronou
              gloomy

              I see the problem in message queue that used by ESB.

              I had create a project that contains some components - a simple Listener, waiting for message and than resend a message to another addressee.

              Some time I receive one message twice. Some times I receive one message except another and otherwise.

              Seems that messages does not removed from queue even if it had received by recipient.

              You can download my project here: http://www.4shared.com/file/16574137/2784c172

              • 4. Re: Problems with delivering the request message sysnchronou
                gloomy

                For those, who want to run my code samples:
                Just import the project into Eclipse and set classpath with the same jars as quickstart projects are.
                Two required launchers are already exists in the project root
                First you must copy mixa-jbmq-service.xml to deploy dir
                Than you must launch "RunComponents"
                And at the end start "TestChain"

                As a result you can see that message you send differ from what you receive. But source code is simple and there is no tricks here.
                Especially see at TIME property - that value must be equals for both incoming and returned message.

                Best wishes!

                • 5. Re: Problems with delivering the request message sysnchronou
                  burrsutter

                  Thank you very much for this and we are looking at it!

                  Burr

                  • 6. Re: Problems with delivering the request message sysnchronou
                    gloomy

                    If you now reload my project from previous link, you may see additional launcher - PerfLoadTest. It use JUnit for testing.

                    • 7. Re: Problems with delivering the request message sysnchronou
                      kconner

                      There is a bug in the code whereby the correlation ID is not being set for the reply address.

                      The result of this is that your calls are receiving any message coming back on the response queue.

                      Also, the JmsConnectionPool currently contains a hardcoded limit of 20 sessions instead of being configurable.

                      I have created two JIRA issues to track this, JBESB-579 and JBESB-580

                      • 8. Re: Problems with delivering the request message sysnchronou
                        gloomy

                        Thank's a lot, Kevin!
                        And can the following code also tend to wrong bechaviour:
                        class SpyMessageConsumer method receive(long timeOut)

                         // Loop through expired messages
                         while (true)
                         {
                         SpyMessage msg = session.connection.receive(subscription, timeOut);
                         if (msg != null)
                         {
                         Message mes = preProcessMessage(msg);
                         if (mes != null)
                         {
                         if (trace)
                         log.trace("receive(long) message from server " + mes.getJMSMessageID() + " " + this);
                         return mes;
                         }
                         }
                         else
                         break;
                         }
                        


                        I see this code can return some messages, that already has been ignored or received by ESB...

                        • 9. Re: Problems with delivering the request message sysnchronou
                          andre1001

                           

                          "Kevin.Conner@jboss.com" wrote:
                          There is a bug in the code whereby the correlation ID is not being set for the reply address.

                          The result of this is that your calls are receiving any message coming back on the response queue.

                          Also, the JmsConnectionPool currently contains a hardcoded limit of 20 sessions instead of being configurable.

                          I have created two JIRA issues to track this, <a href="http://jira.jboss.com/jira/browse/JBESB-579">JBESB-579</a> and <a href="http://jira.jboss.com/jira/browse/JBESB-580">JBESB-580</a>


                          Hi Kevin,

                          the problem on JBESB-580 was solved for the simple case (webservice_war1 sample multithreaded which contains one service).

                          Now, we've got a similar problem with a more complex case based on webservice_war1 sample. We have a dynamic routing service calling a second service (EJB invoker).

                          Is this issue related with the first one? We're preparing an example.

                          Thanks.


                          • 10. Re: Problems with delivering the request message sysnchronou
                            kconner

                             

                            "Andre1001" wrote:
                            Now, we've got a similar problem with a more complex case based on webservice_war1 sample. We have a dynamic routing service calling a second service (EJB invoker).

                            Is this issue related with the first one? We're preparing an example.

                            Please send me your example when it is completed and I will take a look.

                            • 11. Re: Problems with delivering the request message sysnchronou
                              andre1001

                              Kevin,

                              we've just changed jboss-esb.xml (static router service added) and jbmq-service.xml in webservice_war example. It was supposed to get "Hello From ESB MyAction: XXXXXX" as a response, but it gets only "XXXXXX" (the same as the request).

                              jbmq-service.xml

                              <?xml version="1.0" encoding="UTF-8"?>
                              <server>
                               <mbean code="org.jboss.mq.server.jmx.Queue"
                               name="jboss.mq.destination:service=Queue,name=quickstart_webservice_war1_esb">
                               <depends optional-attribute-name="DestinationManager">
                               jboss.mq:service=DestinationManager
                               </depends>
                               </mbean>
                               <mbean code="org.jboss.mq.server.jmx.Queue"
                               name="jboss.mq.destination:service=Queue,name=quickstart_webservice_war1_esb_reply">
                               <depends optional-attribute-name="DestinationManager">
                               jboss.mq:service=DestinationManager
                               </depends>
                               </mbean>
                               <mbean code="org.jboss.mq.server.jmx.Queue"
                               name="jboss.mq.destination:service=Queue,name=quickstart_webservice_war1_esb_2">
                               <depends optional-attribute-name="DestinationManager">
                               jboss.mq:service=DestinationManager
                               </depends>
                               </mbean>
                               <mbean code="org.jboss.mq.server.jmx.Queue"
                               name="jboss.mq.destination:service=Queue,name=quickstart_webservice_war1_esb_2_reply">
                               <depends optional-attribute-name="DestinationManager">
                               jboss.mq:service=DestinationManager
                               </depends>
                               </mbean>
                              </server>
                              


                              jboss-esb.xml

                              <?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-context-factory="org.jnp.interfaces.NamingContextFactory"
                               jndi-URL="localhost" >
                               <jms-bus busid="quickstartEsbChannel">
                               <jms-message-filter
                               dest-type="QUEUE"
                               dest-name="queue/quickstart_webservice_war1_esb"
                               />
                               </jms-bus>
                               <jms-bus busid="quickstartEsbChannel2">
                               <jms-message-filter
                               dest-type="QUEUE"
                               dest-name="queue/quickstart_webservice_war1_esb_2"
                               />
                               </jms-bus>
                               </jms-provider>
                               </providers>
                              
                               <services>
                              
                               <service category="MyServiceCategory"
                               name="MyService"
                               description="WS Frontend speaks natively to the ESB" >
                               <listeners>
                               <jms-listener name="JMS-ESBListener"
                               busidref="quickstartEsbChannel"
                               maxThreads="1"
                               />
                               </listeners>
                               <actions>
                               <action name="routeAction" class="org.jboss.soa.esb.actions.StaticRouter">
                               <property name="destinations">
                               <route-to service-category="MyServiceCategory" service-name="MyService2" />
                               </property>
                               </action>
                               </actions>
                               </service>
                              
                               <service category="MyServiceCategory"
                               name="MyService2"
                               description="WS Frontend speaks natively to the ESB" >
                               <listeners>
                               <jms-listener name="JMS-ESBListener"
                               busidref="quickstartEsbChannel2"
                               maxThreads="1"
                               />
                               </listeners>
                               <actions>
                               <action name="playAction"
                               class="org.jboss.soa.esb.samples.quickstart.webservicewar1.MyAction"
                               process="playWithMessage">
                               <property name="exceptionMethod" value="exceptionHandler"/>
                               </action>
                               </actions>
                               </service>
                               </services>
                              
                              </jbossesb>
                              


                              Thanks.



                              • 12. Re: Problems with delivering the request message sysnchronou
                                kconner

                                 

                                "Andre1001" wrote:
                                we've just changed jboss-esb.xml (static router service added) and jbmq-service.xml in webservice_war example.

                                Thanks. I am currently going through the quick starts but will look at is as soon as I can.

                                • 13. Re: Problems with delivering the request message sysnchronou

                                  Hi Kevin,

                                  I work with Andre1001. Do you have a solution to last problem?

                                  Thanks,

                                  • 14. Re: Problems with delivering the request message sysnchronou
                                    kconner

                                    Hiya Claudio.

                                    I am still tidying up the quickstarts but should be able to look at this tomorrow.

                                    1 2 3 4 Previous Next