Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid MQRC2033 NO_MSG_AVAILABLE

Tags:

ibm-mq

I have a simple program to process messages from a queue. My intention is to process all available messages in queue and still listen to queue for incoming messages.

I have written the processing part inside a infinite loop as i want it to listen to queue always and process messages.

Once after processing all messages again it tries to get a message(as it is inside a infinite loop) from the queue and there

is no messages it throws MQRC 2033 NO_MSG_AVAILABLE exception(infact it is correct) and my program exits.

Can someone give an idea to continously listen to this queue and avoid this exception.

like image 594
Vignesh Avatar asked Jun 25 '11 17:06

Vignesh


1 Answers

When you execute the MQGET API call, there is an option to have the program wait for messages. You can specify a wait time (in milliseconds) or specify to wait forever. Just make sure that if you have the app wait for more than a few seconds, also specify 'Fail if Quiescing'. This allows the queue manager to be stopped cleanly. Without 'Fail if Quiescing' the administrator will need to issue a preemptive shutdown which can cause problems.

There is a section specifically for this question in the Programmer's Guide in the Waiting for Messages chapter. Depending on the language you are writing in ,the actual value to specify is in the Programmer's Reference, the Using Java manual or the Using .Net manual. Each of these will be visible in the navigation panel when you click the link above.

like image 188
T.Rob Avatar answered Nov 17 '22 08:11

T.Rob