|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
Problem with MQQueue.close() hanging |
« View previous topic :: View next topic » |
Author |
Message
|
coolbeans |
Posted: Mon Aug 23, 2004 6:18 am Post subject: Problem with MQQueue.close() hanging |
|
|
 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 |
|
 |
jefflowrey |
Posted: Mon Aug 23, 2004 6:23 am Post subject: |
|
|
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 |
|
 |
coolbeans |
Posted: Mon Aug 23, 2004 6:32 am Post subject: |
|
|
 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 |
|
 |
leongor |
Posted: Tue Aug 24, 2004 5:55 am Post subject: |
|
|
 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 |
|
 |
|
|
 |
|
Page 1 of 1 |
|
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
|
|
|
|