1 Reply Latest reply on Jul 23, 2010 8:53 AM by Tyronne Wickramarathne

    JBOSS 5.1 "MessageConsumer.receiveNoWait(...)" strange problem

    Augustus Karthik Newbie

      Hi,

       

      I am have strange problem with JBOSS 5.1.0. I have attached my program below. This program works perfectly in JBOSS 4.2.3. But fails strangely in Jboss 5.1.0. The strange thing is when I run the same program in "DEBUG" mode it works fine. I couldn't find whats wrong with this program. Is it something related to Threads? Please help me out..

       

      The Main problem is "MessageConsumer.receiveNoWait(...)" method fails to return the ObjectMessage from the JMS Queue event though there are many messages in the queue.

       

      Here is the program:

       

                 initialContext = getContext();

       

                Queue queue = (Queue) initialContext.lookup("/queue/XQueue");

       

                QueueConnectionFactory cf = (QueueConnectionFactory) initialContext.lookup("/ConnectionFactory");

                connection = cf.createQueueConnection("caecmibuser","caecmibuser");

       

                QueueSession qSession1 = connection.createQueueSession(false,    Session.AUTO_ACKNOWLEDGE);

       

                MessageConsumer qReceiver = qSession1.createConsumer(queue);
                     
                connection.start();

       

                 while (true) {
                     ObjectMessage message = (ObjectMessage) qReceiver.receiveNoWait();     //This method always returns null
                     
                      if (message == null)
                          break;

               }

                  qReceiver.close();
                  qSession1.close();
                  connection.close();

       

       

      Thanks

      Augustus