Page 1 of 1

How to process the last msg in MQ?

PostPosted: Fri Sep 03, 2010 3:01 pm
by saintsinner
Hi.. I have a requirement where I need to process the last MQ msg in the Q. The reply to every msg. is the same. Currently the CICS program is designed in such a way that it just reads the first available message, processes it and thats it. It doesnt check to see if there is another message in the Q. The problem with this is, when the CICS is down, the message Q gets built up since the sending system sends message multiple times in a day (for instance, a msg every hour). So, I need to change the program to keep reading the Q till it gets to the last msg. and then process the last msg. What I do not know is, does MQGET populate the message fields with spaces or low-values when there is no msg. left or it will hold the contents of the last successful read? In the former case, I will have to store the msg contents for every MQGET in a temporary WS vairable. In the latter, I need not. Please let me know which is the legitimate way.

Re: How to process the last msg in MQ?

PostPosted: Fri Sep 03, 2010 3:41 pm
by NicC
I am unclear on your requirements - do you want to just access only the last message or do you want to process all the messages in the queue?

Re: How to process the last msg in MQ?

PostPosted: Sat Sep 04, 2010 12:12 am
by dick scherrer
Hello,

What should happen with the messages that are not the last message?

Re: How to process the last msg in MQ?

PostPosted: Mon Sep 06, 2010 7:23 pm
by saintsinner
Since every message in the queue is meant to get the same information, I want to access and process the last (the latest incoming msg) in the queue. Once I am done with processing the last message, I want to delete all the messages. So, I should be able to either read messages in a sequence and delete every message I have read, until I reach the last message OR I can directly access the last message, process it and then delete all the messages in the queue. Either way is ok, however, the latter option sounds better than the former.

Re: How to process the last msg in MQ?

PostPosted: Mon Sep 06, 2010 10:49 pm
by dick scherrer
Hello,

Read each message, store the message in ws, delete the message.

When there are no more, used the stored info to do whatever is needed.

Re: How to process the last msg in MQ?

PostPosted: Wed Nov 10, 2010 10:58 am
by littlechicken
saintsinner wrote:Hi.. I have a requirement where I need to process the last MQ msg in the Q. The reply to every msg. is the same. Currently the CICS program is designed in such a way that it just reads the first available message, processes it and thats it. It doesnt check to see if there is another message in the Q. The problem with this is, when the CICS is down, the message Q gets built up since the sending system sends message multiple times in a day (for instance, a msg every hour). So, I need to change the program to keep reading the Q till it gets to the last msg. and then process the last msg. What I do not know is, does MQGET populate the message fields with spaces or low-values when there is no msg. left or it will hold the contents of the last successful read? In the former case, I will have to store the msg contents for every MQGET in a temporary WS vairable. In the latter, I need not. Please let me know which is the legitimate way.


this sounds like a production problem in the making and a potential disaster. WHy write messages and then never read them only the last you do not mention the secanrio of messages being written tot eh queue.

You could always have a trigger level of 1 then it would start one txn per message received.