Author |
Message
|
Prashant_MQ |
Posted: Thu Jul 27, 2006 11:22 pm Post subject: Not all MQ messages GET processed |
|
|
Apprentice
Joined: 07 Feb 2006 Posts: 28
|
Hi All,
I am facing a strange problem.
Scenario:
1.I trigger off the Request queue
2.PUT some test messages(No messages get processes-as the trigger OFF)
3.Now trigger ON the Request queue.
4.Only one message gets picked up instead of all of them although I have put a logic which checks for MQRC_MESSAGE_NOT_AVAILABLE.
Also below is the design for my code
1.CONNECT to queue manager
2.Repeat below steps until there are no messages on the queue
3.OPEN the request queue
4.GET the message
5.Process the message
6.PUT the reply message in the reply queue.
7.Loop around from step 2
I understand that once the application program terminates,there is an automatic disconnection from the queue manager.
Can anyone help me out on this.
Thanks
Prashant |
|
Back to top |
|
 |
elvis_gn |
Posted: Thu Jul 27, 2006 11:34 pm Post subject: Re: Not all MQ messages GET processed |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi Prashant_MQ,
Prashant_MQ wrote: |
4.Only one message gets picked up instead of all of them although I have put a logic which checks for MQRC_MESSAGE_NOT_AVAILABLE. |
What kind of exception handling are u doing ? Is your application failing or successfully ending ?
Are u doing a trigger every or first ?
Prashant_MQ wrote: |
I understand that once the application program terminates,there is an automatic disconnection from the queue manager. |
No, you should give a queue.close() and qm.close() before exiting...
You should put some print statements and check how ur code is working...
Regards. |
|
Back to top |
|
 |
Mr Butcher |
Posted: Thu Jul 27, 2006 11:48 pm Post subject: |
|
|
 Padawan
Joined: 23 May 2005 Posts: 1716
|
most common reason for an error like this (i get only first message) is, that the storage for holding MQMD and data is the same for all gets, and that msgid and correlid are not reset before the new get. So the first get works, but the second get fails, because the second get tries to read a message with the msgid and corelid from message 1. _________________ Regards, Butcher |
|
Back to top |
|
 |
Prashant_MQ |
Posted: Fri Jul 28, 2006 12:38 am Post subject: |
|
|
Apprentice
Joined: 07 Feb 2006 Posts: 28
|
I am using MQCLOSE
MQOPEN
MQGET
MQCLOSE
MQPUT-to reply queue
Can you confirm that MQCLOSE qill surely disconnect from the queue manager.
Becuase I need the connection handle since I am implemeting a GET in a LOOP.
Does it mean that I need issue MQCONN again before I do the next GET.(since I have issued MQCLOSE)
Please let me know
Thanks
Prashant |
|
Back to top |
|
 |
elvis_gn |
Posted: Fri Jul 28, 2006 12:56 am Post subject: |
|
|
 Padawan
Joined: 08 Oct 2004 Posts: 1905 Location: Dubai
|
Hi Prashant_MQ,
Prashant_MQ wrote: |
Becuase I need the connection handle since I am implemeting a GET in a LOOP.
Does it mean that I need issue MQCONN again before I do the next GET.(since I have issued MQCLOSE) |
Don't connect and disconnect for every get....do a disconnect at the end of all picks...
But that is not the issue right ?
Prashant_MQ wrote: |
4.Only one message gets picked up instead of all of them although I have put a logic which checks for MQRC_MESSAGE_NOT_AVAILABLE. |
This seemed to be your issue...
Regards. |
|
Back to top |
|
 |
wschutz |
Posted: Fri Jul 28, 2006 3:23 am Post subject: |
|
|
 Jedi Knight
Joined: 02 Jun 2005 Posts: 3316 Location: IBM (retired)
|
The model you should use for a triggered program is:
Code: |
MQCONN
MQOPEN input queue
loop until MQGET fails
MQGET with wait and reset msgId/correlID
if MQGET worked
process message
MQPUT1 to reply queue
end-loop
MQCLOSE
MQDISC
|
If you close the queue while messages are still on it (which appears to be the case here), the qmgr will create another trigger messsage and you'll have two copies of your program running. _________________ -wayne |
|
Back to top |
|
 |
Prashant_MQ |
Posted: Mon Jul 31, 2006 5:40 am Post subject: |
|
|
Apprentice
Joined: 07 Feb 2006 Posts: 28
|
Wayne,
I have coded exactly the same way as you have mentioned in your reply below.
At the same time I tried to understand the exact mening of trigger type FIRST and EVERY.
Here is what happened-
I put the loop(to get messages until there are none) with trigger type EVERY,it did not work.Only one message gets processed each time a message is put in the queue(when there are already messages lying on the queue)
I changed the trigger type to FIRST and all the messages got picked up-note that loop is still present in the code.
Now I removed the loop(for get messages)-trigger off the queue --put 3 messages,the messages stayed in the queue which is valid.
I triggered on the queue(note that the trigger type is FIRST),although there was no loop(to get messages) all messages disappeared.
How is this possbile.What I understand is that for trigger type FIRST all messages will be processed until there are none on the queue(this should be done by the application program) as only one trigger message is created.
I am getting confused.I dont undertsand if my code is incorrect or it is the magic of trigger type.I guess there is some attribute which tells the program that there are more messages and you need to pick them all instead of specifically having the loop in the code.
Please clarify my doubts.
Thanks in advance
Prashant |
|
Back to top |
|
 |
Vitor |
Posted: Mon Jul 31, 2006 5:51 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
The way to tell if a queue is empty is the 2033 reason code; there is an attribute as you say (CURRDEPTH) but it's a long winded way round a simple problem!!!
Staying with the concept of simple can you confirm:
a) When all the messages disappeared after FIRST, the version of your application really didn't have the loop in it. It's so easy to accidently run the wrong version when you've chopping and changing.
b) The test really was with FIRST not EVERY. Again it's a simple thing and no offence is intended but it really is so easy to do.
It sounds like your understanding is correct but you have some code or setup issue. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
zpat |
Posted: Mon Jul 31, 2006 5:51 am Post subject: |
|
|
 Jedi Council
Joined: 19 May 2001 Posts: 5866 Location: UK
|
Use MQGET with MQGMO_WAIT and set the wait interval to a reasonable value (eg 5 seconds) - even when using triggering and a loop.
The reasons are (1) sometimes a trigger can be set before the messages are available and (2) more messages might arrive very shortly after the last one, so it saves triggering the program again within a short period. |
|
Back to top |
|
 |
Prashant_MQ |
Posted: Mon Jul 31, 2006 6:04 am Post subject: |
|
|
Apprentice
Joined: 07 Feb 2006 Posts: 28
|
I confirm on the below points
a) When all the messages disappeared after FIRST, the version of your application really didn't have the loop in it. It's so easy to accidently run the wrong version when you've chopping and changing.
Yes,there is no loop in the code and trigger tpye is FIRST.
b) The test really was with FIRST not EVERY. Again it's a simple thing and no offence is intended but it really is so easy to do.
Yes,test was for FIRST.
I shall wait for the CICS regions to bounce try and test this tomorrow again.
I guess this one is going to ruin my tonight's sleep.
Anyways,thanks all for your replies.I will be back tomorrow with some more test results.
Prashant |
|
Back to top |
|
 |
|