Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Java: accessing the rollback counter

269 views
Skip to first unread message

Robert Löwenstein

unread,
Feb 24, 2003, 2:14:07 PM2/24/03
to
Hi,

i am using the base java classes (com.ibm.mq.jar – no JMS) to connect to
MQ.

Is there a way to access (read and set) the rollback counter of a
message ?


To set up a connection, i basically do the following:
...
MQEnvironment.properties.put(
MQC.TRANSPORT_PROPERTY,
MQC.TRANSPORT_MQSERIES);
...
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT;
MQQueue qSend = qMgr.accessQueue("MY_QUEUE", openOptions, null, null,
null);
...

Do I have to make a special MQEnvironment setting, or use different
openOptions to use the rollback feature of MQ ?


cu,
Robby


RogerLacroix

unread,
Feb 25, 2003, 1:20:35 AM2/25/03
to
I'll assume you want to do "local" units of work (vs global).

After you have openned the queue, any messages that you want to be of
the local unit of work (get or put) you mark with the sync-point option.
i.e. for get use MQC.MQGMO_SYNCPOINT and for put use MQC.MQPMO_SYNCPOINT

Then to commit or rollback the local unit of work, you use the methods
commit() or backout() of class MQQueueManager.

Read the WebSphere MQ Using Java manual (chapter 9) for more
information.

later Roger...

--
posted via MFF : http://www.MainFrameForum.com - USENET Gateway

Robert Löwenstein

unread,
Feb 25, 2003, 2:19:54 AM2/25/03
to
RogerLacroix wrote:

> I'll assume you want to do "local" units of work (vs global).

To be honest - i am not shure. Somebody told me there is a "rollback
counter" in MQ.
So the first question would be: Is this really true ?

> Then to commit or rollback the local unit of work, you use the methods
> commit() or backout() of class MQQueueManager.

Are these rollbacks counted ?
So: Is there a rollback counter for each message ? And if so - is there a
java method for reading this counter ? Or must i take an admin tool ?

cu,
Robby

Peter Rilke

unread,
Feb 25, 2003, 3:15:11 AM2/25/03
to
RogerLacroix wrote:

> I'll assume you want to do "local" units of work (vs global).

I have a related problem ...

> Then to commit or rollback the local unit of work, you use the methods
> commit() or backout() of class MQQueueManager.

How can i find out if i already tried to process a message ?

If there is no way to detect this, i would be captured in a loop:

- read message() -> got message 1
- rollback message(1)
- read message() -> got message 1 (again)
- rollback message(1)
...

Is it possible to read a rollback flag or counter from a message ?


best regards,
Peter Rilke

zpat

unread,
Feb 25, 2003, 8:37:38 AM2/25/03
to
Each message will have a "backout count". You can access this from any
MQI language - see the manuals.

You can choose to make the application deal with messages that have been
backed out more than "n" times, or set a backout threshold and backout
queue name in the queue definition and let the queue manager deal with
them for you (eg send to deal letter queue).

RogerLacroix

unread,
Feb 26, 2003, 4:28:47 AM2/26/03
to
No, no, no zpat. The queue manager will NEVER do anything with a message
based on the backout threshold count. Everything must be dealt with at
the application level.

Peter / Robert, here is what you do:

1) First you need to set the BackoutRequeueQName and BackoutThreshold.
These are attributes of a queue. Lets say your application queue is
ABC.Q and the backout queue is called ABC.Q.BK and you want to do a
max of 3 rollbacks. So, you need to update the queue attributes as
follows (your MQ Admin may need to do this command): ALTER Q(ABC.Q)
BOQNAME(ABC.Q.BK) BOTHRESH(3)
2) Now in your application program when you open the queue make sure you
specify the inquire option (for 'C' use MQOO_INQUIRE, for Java use
MQC.MQOO_INQUIRE).

2a) For 'C' programs (or COBOL) you will need to issue a MQINQ call
specifying MQIA_BACKOUT_THRESHOLD and MQCA_BACKOUT_REQ_Q_NAME
attributes.
2b) For Java programs, use the class MQManagedObject and use the
inquire() method (same attributes). Save the values returned
from the call.

3) In your program, each time you get message (under SyncPoint) you will
compare the backout count of the message descriptor (MQMD) with the
saved value from step #3 above. i.e. if MQMD.backoutCount >
Saved.Threshold then MQPUT message to Saved.RequeueName else // life
is good - continue Hope that helps.

later Roger...

Ron Bower

unread,
Feb 26, 2003, 11:47:50 AM2/26/03
to
Go take a look at backout.java located on
http://www.developer.ibm.com/tech/sampmq.html. It is a java program that
moves a message to the backout queue. It should help.

Ron Bower
IBM Developer Relations WebSphere MQ Support

"RogerLacroix" <mem...@mainframeforum.com> wrote in message
news:b3i1cf$2dk2$6...@news.boulder.ibm.com...

0 new messages