|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
backout not reinstating messages on the queue |
« View previous topic :: View next topic » |
Author |
Message
|
OEvans |
Posted: Fri Sep 20, 2002 12:25 pm Post subject: backout not reinstating messages on the queue |
|
|
Newbie
Joined: 13 Sep 2002 Posts: 6 Location: Vancouver, B.C.
|
I written a java class that, among other things, attempts to retreive a group of message from a queue. Getting the group works fine but if there is a problem and I try to backout I have noticed the the messages I have pulled off of the queue are not reinstated back onto the queue. This is my first crack at MQSeries programming so I assume I am not understanding something. Can anyone explain why, after I call backout(), the messages I got are still missing from the queue? Am I just not understanding the purpose of backout properly?
-------
code
-------
public MQMessage[] getMessageGroup()
throws MQException, IOException
{
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_FAIL_IF_QUIESCING;
MQQueue queue = queueMgr.accessQueue(queueName, openOptions, null, null, null);
Vector msgGroup = new Vector();
MQGetMessageOptions getOptions = new MQGetMessageOptions();
getOptions.options = getMessageOptions +
MQC.MQGMO_SYNCPOINT +
MQC.MQGMO_WAIT +
MQC.MQGMO_ALL_MSGS_AVAILABLE +
MQC.MQGMO_LOGICAL_ORDER;
getOptions.matchOptions = MQC.MQMO_MATCH_GROUP_ID;
try {
while(true){
MQMessage incoming = new MQMessage();
queue.get(incoming, getOptions);
msgGroup.add(incoming);
char x = getOptions.groupStatus;
if (x == MQC.MQGS_LAST_MSG_IN_GROUP){
break;
}
int groupSize = msgGroup.size();
MQMessage[] messages = new
MQMessage[groupSize];
msgGroup.copyInto(messages);
queueMgr.commit();
queue.close();
return messages;
} catch (MQException mqex){
queueMgr.backout();
}
return null;
} |
|
Back to top |
|
 |
bower5932 |
Posted: Wed Sep 25, 2002 10:20 am Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
I don't see anything obvious. You might want to look at the mqsync.java in the code repository. I know that it is a java program that does commits and backouts. |
|
Back to top |
|
 |
vennela |
Posted: Wed Sep 25, 2002 12:13 pm Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
I didn't see any MQBegin in the code. Ususally I do this
MQConn
MQOpen
MQBegin
a bunch of MQGets
MQCmit/MQBack
MQClose
MQDisc
Not sure if this is the problem.
Are the messages persistent or non-persistent messages?
---
Venny |
|
Back to top |
|
 |
vennela |
Posted: Wed Sep 25, 2002 5:25 pm Post subject: |
|
|
 Jedi Knight
Joined: 11 Aug 2002 Posts: 4055 Location: Hyderabad, India
|
I am sorry, I was talking about batch processing in my previous reply.
The story of SYNCPOINT is:
1. Queue is defined to hold non-persistent messages
In this case if there is an error (an immediate shutdown of the QMGR) an exception is thrown. This exception is caught and you are trying to do a backout saying
queueMgr.backout();
But by this time the QueueManager handle is broken (MQRC 2009) and this statement throws another exception, which means backout was not successful.
Since the Queue is defined to hold non-persisten queues QMGR simply disregards the messages in the Queue.
2. Queue is defined to hold persistent messages
The same thing as above happens but since the Queue is suppose to have persistent messages QMGR takes care of the messages (your application or queueMgr.backout() doesn't do any good).
In the first case, if the exception that is thrown is such that the QueueManager handle is not broken then the messages are reinstated. So it really depends on the exception thrown.
---
Venny |
|
Back to top |
|
 |
bower5932 |
Posted: Thu Sep 26, 2002 12:25 pm Post subject: |
|
|
 Jedi Knight
Joined: 27 Aug 2001 Posts: 3023 Location: Dallas, TX, USA
|
I'm not sure that I agree with your dependence of Syncpoint on message persistence.
A persistent message will survive a qmgr shutdown and restart. A non-persistent message won't. This has nothing to do with syncpoint. Although to be honest, I'm not sure why you would do things with persistent messages out of syncpoint. If the message is important enough to persist, it is probably involved in a unit of work.
Syncpoint indicates that you want to get/put a message inside of a unit of work. When you are ready, you either commit or backout. If you are getting messages and issue the backout, the messages are put back on the queue. If you are putting messages and issue the backout, the messages are never put on the queue.
The Application Programming Reference has a discussion in it regarding uncommitted units of work when you either MQDISC or terminate without the MQDISC. It is in the MQCMIT section. I don't remember all of the details, but I do remember that there are differences based on the OS. |
|
Back to top |
|
 |
OEvans |
Posted: Sun Sep 29, 2002 9:54 am Post subject: |
|
|
Newbie
Joined: 13 Sep 2002 Posts: 6 Location: Vancouver, B.C.
|
Thanks for everyone's replies. You have given me a few things to work with and try out. I will work on it tomorrow and let you know what happens. |
|
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
|
|
|
|