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 API Support » MQSeries Client - MQCMIT / MQBACK program logic query.

Post new topic  Reply to topic
 MQSeries Client - MQCMIT / MQBACK program logic query. « View previous topic :: View next topic » 
Author Message
jconway
PostPosted: Thu Jun 19, 2003 4:13 am    Post subject: MQSeries Client - MQCMIT / MQBACK program logic query. Reply with quote

Novice

Joined: 28 Apr 2003
Posts: 17
Location: Paris, France

Hello,
I'm wondering if someone can advise me on how to solve the following dilemna.
My application running as an MQSeries Client has the following (very) basic program logic :-

MQCONN to queue manager
MQOPEN queue for output
MQGET msg under SYNCHPOINT
Process the message
If process successful
MQCMIT
Else
MQBACK with the future desire to MQGET this message again and
try to process it again.
Loop to MQGET to get next message on the Queue

Note - if the connection is lost then the client tries to reconnect.

Now, here's my dilemna.

If I lose the connection to the Queue Manager after processing the message but before the MQCMIT or the MQBACK is done, then, when the proxy code in the Queue Manager (that issues the MQI verbs on the Client's behalf) realises that the connection to the Client is lost, he will back out the message and the message will become visible again on the queue with the backout counter incremented.
So far so good.
After the Client reconnects, the MQGET will find this message but I have no way of telling whether this was a message I had originally intended to MQCMIT (ie. Remove permanently from the queue and NOT process it again) or to MQBACK (ie. I DO want to process it again).

I'm sure there's an obvious way around this that I'm missing or that my basic understanding of the above processing is flawed, I'm new to MQ. I would really appreciate any suggestions as to how to solve this issue.
Thanks, Jim.
Back to top
View user's profile Send private message Send e-mail
mqonnet
PostPosted: Thu Jun 19, 2003 6:29 am    Post subject: Reply with quote

Grand Master

Joined: 18 Feb 2002
Posts: 1114
Location: Boston, Ma, Usa.

After you have successfully got the message under syncpoint, if the connection fails or for some reason MQ had to backout the message, then there is no way for MQ to intimate the application of the same, but one.

And which is, through MQCMIT call. Since your get passed successfully, your app would go through the commit logic and would try and issue MQCMIT. When it does so, it would get a reason code MQRC_BACKED_OUT which you need to handle appropriately in your code. When you do so, you can as well store the msgid/correld and any other distinguishing attributes of your message. So that when you do a get next time, and co-incidently get the same message again, you know that this is the one that you were trying to process or rather processed(since i dont know what "process the message" does in your app).

Hope this helps.

Cheers
Kumar
Back to top
View user's profile Send private message Send e-mail Visit poster's website
jconway
PostPosted: Thu Jun 19, 2003 7:15 am    Post subject: Reply with quote

Novice

Joined: 28 Apr 2003
Posts: 17
Location: Paris, France

Thanks a million for your reply. I still have a couple of questions.

1. If I do an MQGET of a message then the connection between my MQ Client and the Queue Manager is lost and THEN I try to do an MQCMIT won't I get a MQRC_CONNECTION_BROKEN reason code from the MQCMIT?
(Also, apparently with Clients, there is a possibility that the commit may have actually worked even if this reason code is received .. bizare!).

2. Am I correct in thinking that when an MQBACK is performed the message becomes visible once more on the queue but it's position on the queue remains unaltered (ie. it's the first on the queue, I do a get with SYNCHPOINT, a second message arrives on the queue, then if I do an MQBACK it becomes visible as the first message on the queue again BEFORE the second message that arrived)?

Thanks for the "store the MsgId" idea. That's definitely the way I'll go.
Really appreciate the help.
Jim.
Back to top
View user's profile Send private message Send e-mail
zpat
PostPosted: Thu Jun 19, 2003 7:25 am    Post subject: Reply with quote

Jedi Council

Joined: 19 May 2001
Posts: 5866
Location: UK

One other tip - you can inspect the "backout count" in the message header to see how many times it had already been read and backed out.

If this value is above "n", you might want to abandon the attempt to process it to avoid a loop. Alternatively set a "backout requeue queue" on the queue definition with a threshold "n", so that the queue manager will automatically send it to this other queue when it has been backed out "n" times on the original queue.

I recommend using a backout queue in the definitions as a safeguard because your code might even fail before you can read the backout value in the message (it's happened to me!) and loop indefinitely.

Using XA coordination can ensure a consistent state between a queue and a database.


Last edited by zpat on Thu Jun 19, 2003 8:14 am; edited 1 time in total
Back to top
View user's profile Send private message
mqonnet
PostPosted: Thu Jun 19, 2003 7:34 am    Post subject: Reply with quote

Grand Master

Joined: 18 Feb 2002
Posts: 1114
Location: Boston, Ma, Usa.

Backoutcount suggested by zpat is also a good way to go.

Yeah, with clients you have the drawback of having inconsistency in the event of a "pull the plug" scenario or a similar one. And hence you have to code your application to handle such instances.

As for the return code, i guess you would get connection_broken.

Cheers
Kumar
Back to top
View user's profile Send private message Send e-mail Visit poster's website
bower5932
PostPosted: Thu Jun 19, 2003 8:03 am    Post subject: Reply with quote

Jedi Knight

Joined: 27 Aug 2001
Posts: 3023
Location: Dallas, TX, USA

For what it is worth, there are a couple of programs on

http://www.developer.ibm.com/tech/sampmq.html

that show backing out a message. One is in C and the other in java.
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » IBM MQ API Support » MQSeries Client - MQCMIT / MQBACK program logic query.
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.