[jboss-user] [JBoss Messaging] - JBOSS 5.1 "MessageConsumer.receiveNoWait(...)" strange problem

Augustus Karthik do-not-reply at jboss.com
Wed Jul 21 07:57:05 EDT 2010


Augustus Karthik [http://community.jboss.org/people/augustusk] created the discussion

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

To view the discussion, visit: http://community.jboss.org/message/553680#553680

--------------------------------------------------------------
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

--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/553680#553680]

Start a new discussion in JBoss Messaging at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2042]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20100721/26b6966c/attachment.html 


More information about the jboss-user mailing list