ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » IBM MQ Java / JMS » Problem with MQQueue.close() hanging

Post new topic  Reply to topic
 Problem with MQQueue.close() hanging « View previous topic :: View next topic » 
Author Message
coolbeans
PostPosted: Mon Aug 23, 2004 6:18 am    Post subject: Problem with MQQueue.close() hanging Reply with quote

Novice

Joined: 16 Jul 2004
Posts: 20
Location: London, UK

I have created a subscribe method, which listens to messages as they are put on the queue. The problem I am having is that I believe the MQQueue.get() method is synchronized on the queue manager and so when I call myStopListening() method the MQQueue.close() method (which is also synchronized on the queue manager) it causes my program to hang.

So my question is, is there any way to exit/notify the MQQueue.get() method without putting a message on the queue or is there a way to close the queue successfully even though it is still 'getting'?
Code:

myListenMethod(MQQueue mqQueue)
{
      MQGetMessageOptions gmo = new MQGetMessageOptions();

      gmo.waitInterval = MQC.MQWI_UNLIMITED;

      gmo.options = MQC.MQGMO_WAIT | QC.MQGMO_BROWSE_FIRST;
         
      MQMessage message = new MQMessage();

      // m_listening is a boolean
      while(m_listening)
      {
            // Reset the message and IDs to be empty
            message.clearMessage();

            // get the message
            mqQueue.get(message, gmo);

            doSomethingWithMessageMethod(message);
     }
}

myStopListeningMethod()
{
   m_listening = false;

   // the following line causes the program to hang
   mqQueue.close();
}
Back to top
View user's profile Send private message
jefflowrey
PostPosted: Mon Aug 23, 2004 6:23 am    Post subject: Reply with quote

Grand Poobah

Joined: 16 Oct 2002
Posts: 19981

Either don't use MQC.MQWI_UNLIMITED, or create a "stop listening" message and code your application to understand that.

You should also add the Fail On Quiescing option to your GetMessageOptions.
_________________
I am *not* the model of the modern major general.
Back to top
View user's profile Send private message
coolbeans
PostPosted: Mon Aug 23, 2004 6:32 am    Post subject: Reply with quote

Novice

Joined: 16 Jul 2004
Posts: 20
Location: London, UK

yeah, I was hoping there would be another way. I can't put messages on the queue so the second option is out the window. Which leaves the first option which isn't nice as it means I effectively have to poll for messages which means I have to make decisions about how often to poll.
Thanks anway.
p.s. added Fail On Quiescing
Back to top
View user's profile Send private message
leongor
PostPosted: Tue Aug 24, 2004 5:55 am    Post subject: Reply with quote

Master

Joined: 13 May 2002
Posts: 264
Location: Israel

Usually there are 2 methods :
1. Put administrative message on the queue telling to application to end.
2. Disable a queue for get and handle an exception Queue Inhibit in a program.
_________________
Regards.
Leonid.

IBM Certified MQSeries Specialist.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ Java / JMS » Problem with MQQueue.close() hanging
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.