12 Replies Latest reply on Jul 14, 2009 2:57 AM by gaohoward

    JBoss Messaging not working as expected

      Hi.

      I've got some serious problems using JBoss Messaging. I got the Server JBoss AS 4.2.3.GA and the Messaging instance up and running. When I sending messages from one application on one queue to another application everything works fine. But when I use 5 sending and 5 receiving applications on 5 diffent queues the system is damn slow and it fails to transmit all messages. 2 Messages where left behind in every queue!

      I don't have any idea what I am doing wrong.

      Some details:

      Platform: SuSe Linux 10.1
      Server: JBoss AS 4.2.3.GA (defult installation)
      JBoss Messaging: 1.4.2. GA-SP1 (default installation)


      hope that someone can help me with that!


      So long!

      Alexander

        • 1. Re: JBoss Messaging not working as expected
          gaohoward

          Does it always happen or sometimes?

          • 2. Re: JBoss Messaging not working as expected
            ataylor

            How do you know messages are left in the queue?

            when are you starting the consumers, messages can be buffered by a client so it may be that the first consumer to connect has all the messages sitting in its buffer.

            Post your code so we can take a look.

            • 3. Re: JBoss Messaging not working as expected

              Hi.

              I had a look in the JMX interface and there it says that 2 messages are pending in the queue.

              There is only one producer, consumer on each queue. So it should not happen that one consumer buffers messages from another queue.


              The producer should send 10.000 messages to one queue and the receivers expect to receive 10.000 messages. The receivers will prompt a message when all messages are received.


              Producer:

              initialization:

              public void init(String ip, int port, String qname) throws Exception {
               connection = createConnection(ip, port);
               connection.start();
               session = connection
               .createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
               try {
               q = (Queue) ctx.lookup(qname);
               } catch (Exception e) {
               q = session.createQueue(qname);
               ctx.bind(qname, q);
               }
               producer = session.createSender(q);
               }
              
               public QueueConnection createConnection(String ip, int port)
               throws NamingException, JMSException {
               try {
               ctx = (InitialContext) createContext(ip, 1099);
               } catch (Exception e) {
               e.printStackTrace();
               }
               QueueConnectionFactory qcf = (QueueConnectionFactory) ctx
               .lookup("ConnectionFactory");
               return qcf.createQueueConnection();
               }
              
              protected Context createContext(String ip, int port) throws Exception {
               String host = "jnp://" + ip + ":" + port;
               return createContext(host);
               }
              
               protected Context createContext(String host) throws Exception {
               Properties props = new Properties();
              
               props.put(Context.INITIAL_CONTEXT_FACTORY,
               "org.jnp.interfaces.NamingContextFactory");
               props.put(Context.PROVIDER_URL, host);
               props.put(Context.URL_PKG_PREFIXES,
               "org.jboss.naming:org.jnp.interfaces");
              
               return new InitialContext(props);
               }
              


              sending messages:
              public void sendMsg(String msgtxt) throws Exception {
               TextMessage simpleMessage = session.createTextMessage();
               simpleMessage.setText(msgtxt);
               producer.send(simpleMessage);
               }
              



              Consumer implements MessageListener:

              inititalization:
              private void init(String ip, int port, String qname) throws JMSException,
               NamingException {
               connection = createConnection(ip, port);
               connection.start();
               session = connection.createQueueSession(false,
               QueueSession.AUTO_ACKNOWLEDGE);
               Queue q = session.createQueue(qname);
               msgConsumer = session.createReceiver(q);
               msgConsumer.setMessageListener(this);
               }
              
              public QueueConnection createConnection(String ip, int port)
               throws NamingException, JMSException {
               try {
               ctx = (InitialContext) createContext(ip, 1099);
               } catch (Exception e) {
               e.printStackTrace();
               }
               ConnectionFactory tmp = (ConnectionFactory) ctx
               .lookup("ConnectionFactory");
               QueueConnectionFactory qcf = (QueueConnectionFactory) tmp;
               return qcf.createQueueConnection();
               }
              
               // the default method
               protected Context createContext(String ip, int port) throws Exception {
               String host = "jnp://" + ip + ":" + port;
               return createContext(host);
               }
              
               protected Context createContext(String host) throws Exception {
               Properties props = new Properties();
              
               props.put(Context.INITIAL_CONTEXT_FACTORY,
               "org.jnp.interfaces.NamingContextFactory");
               props.put(Context.PROVIDER_URL, host);
               props.put(Context.URL_PKG_PREFIXES,
               "org.jboss.naming:org.jnp.interfaces");
              
               return new InitialContext(props);
               }
              


              receiving messages:
              public void onMessage(Message msg) {
               cnt = cnt + 1;
               TextMessage txtMsg = (TextMessage) msg;
               if (cnt == msgToReceive) {
               running = !running;
               System.out.println(getClientId() + " Received all msg @ "
               + System.currentTimeMillis());
               cnt = 0;
               } else if (cnt > msgToReceive) {
               cnt = 0;
               }
               }
              




              • 4. Re: JBoss Messaging not working as expected
                ataylor

                Can you try jboss 5.0.1.GA, messaging is the default jms provider with this.

                • 5. Re: JBoss Messaging not working as expected

                  Thanks for the advice, I'm going to try it!

                  • 6. Re: JBoss Messaging not working as expected

                    Hi.

                    I've now tried using JBoss AS 5.0.1GA as suggested but the problem remains the same.

                    Any advice?

                    Alex

                    • 7. Re: JBoss Messaging not working as expected
                      timfox

                      If you create a JIRA and attach a self contained test program that we can run to replicate the issue, someone can take a look at it.

                      • 8. Re: JBoss Messaging not working as expected

                        Hi!

                        Can you please tell me the link to JIRA and what do you mean with "self contained test"? Do you mean the source of the program i am using?

                        So long!
                        Alex

                        • 9. Re: JBoss Messaging not working as expected
                          gaohoward

                          https://jira.jboss.org/jira/browse/JBMESSAGING

                          If you have a program that can reproduce the issue, it will be perfect for us to solve it. Thanks.

                          • 10. Re: JBoss Messaging not working as expected
                            gaohoward

                            Hi, I did a simple test as follows:

                            1. start up a JBM node which has 5 queues deployed. They are A, B, C, D, E
                            2. start 5 processes on another machine. Each process continuously sends and receive messages from a different queue.

                            My results is that all the process works normally, all messages sent have been received.

                            My question is how long before you find the message delivering start to slow down?

                            • 11. Re: JBoss Messaging not working as expected

                              Hi.

                              Finally i managed to create a jira task and attached my eclipse project.

                              If anyone could have a look at it and help me it would be great.

                              Here is the link to jira: https://jira.jboss.org/jira/browse/JBMESSAGING-1684

                              Thanks in advance.

                              @gaohoward: If i use 1 queue it works just fine. Even with 5 queues it works most of the time but with for example 10 queues i never successfully finished a test.


                              -Alex

                              • 12. Re: JBoss Messaging not working as expected
                                gaohoward

                                That's great Alex. I'll take a look. Thanks.

                                Howard