5 Replies Latest reply on Jul 21, 2009 5:02 AM by ejb3workshop

    Clustered messages not being received by external client

    ejb3workshop

      I am submitting messages from an external Java application to my JBoss AS 4.2.3 running JBM 1.4.4 GA. The messages are being received and distributed across all nodes in the cluster. After processing the application responds via a message on a "response" queue.

      For some strange reason these response message seems to be linked to specific nodes. When I log into the JMX console I can see the messages, however when I try to receive them in my external Java client I am only able to access the message sent to the node I am connecting to.

      I had a look on the forum but didn't find anything. As receiving is strickly speaking working it seems to be a cluster specific issue. I have defined the message destination using a jms-services.xml file included in an EAR file together with my EJB3 MDB. I have tried using the clustered connection factory as well as JMSXA to sent the responses.

      Any suggestions on what to try or how I could resolve this would make my day.

      Thanks in advance
      Alex

        • 1. Re: Clustered messages not being received by external client
          clebert.suconic

          This is probably due to the way JBoss Messaging works regarding the local queues.

          Message are aways sent to the local server, until you need move messages.

          Take a look on the manual and WIKIs about how clustering works on JBoss messaging 1.4.

          • 2. Re: Clustered messages not being received by external client
            ejb3workshop

            Surely this can't be the case. It would be a big problem for me if I were not able to deliver outbound messages to external clients. It is not viable for the client to know which cluster node will respond. Not even sure if this is possible since the messages are distributed at random / round robin.

            Has this been resolved in release 2.x of JBoss Messaging and can I integrate that release into JBoss 4.2.3 / JBoss EAP ?

            Thanks in advance.

            • 3. Re: Clustered messages not being received by external client
              gaohoward

              Did you deploy the 'response queue' as distributed queue?
              Can you put it's configuration here? thanks.

              • 4. Re: Clustered messages not being received by external client
                timfox

                If you have a queue called "responseQueue" deployed on each of your nodes, how can JBoss Messaging possibly know which actual version of responseQueue on what node to send the response to? JBM is not psychic ;)

                It can't, you simply haven't given it enough information.

                The proper way of implementing this pattern is to implement a temporary response queue which will have a unique name across the cluster, then when you send a response to it from any other node, JBM will unambiguously know where to route it, otherwise it has no idea which node to route it to.

                Alternatively you can create a response topic and consume responses with a selector (response_id=X). Either way will work.

                BTW There are tests in the test suite for this.

                • 5. Re: Clustered messages not being received by external client
                  ejb3workshop

                  I am defining the destinations in abc-services.xml which is referenced in the jboss-app.xml file. Both these are included in the EAR file containing the MDBs. This application is deployed into the farm folder of the JBoss nodes in the cluster. My assumption is that since the destinations are set to be clustered and the application is deployed into the cluster wide farm folder JBoss would be able to figure it out. Any messages sent to JBoss are distributed across the clustered nodes, so it seems to work for receiving messaged inside JBoss. The JMX console also only shows a single destination, which is what I would have expected.

                  <?xml version="1.0" encoding="UTF-8"?>
                  <server>
                  ...
                   <mbean code="org.jboss.jms.server.destination.QueueService"
                   name="jboss.messaging.destination:service=Queue,name=Responses"
                   xmbean-dd="xmdesc/Queue-xmbean.xml">
                   <attribute name="JNDIName">queue/abc/Responses</attribute>
                   <depends optional-attribute-name="ServerPeer">jboss.messaging:service=ServerPeer</depends>
                   <depends>jboss.messaging:service=PostOffice</depends>
                   <attribute name="Clustered">true</attribute>
                   </mbean>
                  </server>
                  


                  The problem is only apparent when the receiving client is a stand-alone application running outside the application server.

                  This is the code I use to receive the messages.

                  InitialContext jndiContext = new InitialContext(props);
                  
                  // connect to JNDI to get JMS Queue Factory
                  QueueConnectionFactory qFactory = (QueueConnectionFactory) jndiContext.lookup("ClusteredConnectionFactory"); // e.g. javax.jms.QueueConnectionFactory
                  
                  
                  // look up and connect to Response Queue
                  System.out.println("Connecting to JMS Response Queue: " + props.getProperty("jmsResponseQueue"));
                  Queue responseQ = (Queue) jndiContext.lookup("queue/abc/Responses");
                  QueueConnection responseQconn = qFactory.createQueueConnection();
                  QueueSession responseQSession = responseQconn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
                  QueueReceiver responseQrecv = responseQSession.createReceiver(responseQ);
                  System.out.println("Ready to receive messages");
                  responseQconn.start();
                  
                  Message msg = responseQrecv.receive(60000);
                  ...
                  


                  Thanks in advance.
                  Alex