|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
JAVA IBM MQ Destructive Read Message from Queue |
« View previous topic :: View next topic » |
Author |
Message
|
venkata.silla4u |
Posted: Tue May 21, 2019 8:23 pm Post subject: JAVA IBM MQ Destructive Read Message from Queue |
|
|
Newbie
Joined: 21 May 2019 Posts: 2
|
Hi All,
I m trying to read a message from queue and auto delete the message after successfully reading it i.e., destructive read.Some how i tried all the mq options as mentioned below,Though i m able to successful read the message from CICS output queue, i still see a copy of the read message still remains in the queue.which leads to the queue messages pilling up. Need some help if i'm missing anything here on destructive read.
//defining the mq queue object
MQQueue docRespQObj = queueManagerObj.accessQueue(docResQ, CMQC.MQOO_INQUIRE + CMQC.MQOO_FAIL_IF_QUIESCING + CMQC.MQOO_INPUT_SHARED);
//Code to read message from queue, descructive read is not working here.
MQMessage messageObj = new MQMessage();
mqGMO = new MQGetMessageOptions();
mqGMO.matchOptions = MQConstants.MQMO_MATCH_CORREL_ID;
mqGMO.options = MQConstants.MQGMO_WAIT;
mqGMO.waitInterval = waitInterval;
// wait interval
messageObj.correlationId = correlationId;
long startTime = System.currentTimeMillis();
docRespQObj.get(messageObj, mqGMO);
int payloadLength = messageObj.getMessageLength();
msgPayload = new byte[payloadLength];
messageObj.readFully(msgPayload);
Please advice if i'm missing any GMO or MQ options.Thank you. |
|
Back to top |
|
 |
PaulClarke |
Posted: Tue May 21, 2019 10:10 pm Post subject: |
|
|
 Grand Master
Joined: 17 Nov 2005 Posts: 1002 Location: New Zealand
|
If you don't tell MQ z/OS explicitly whether you want sync-point or not then it will assume that you do want sync-point (ie. in a transaction). Unfortunately Distributed MQ went the other way and assumed no sync-point. So, it is always a good idea to be explicit about whether you want transactions involved.
So, I would suggest you add MQGMO_NO_SYNCPOINT to your MQGMO_WAIT get options,
Cheers,
Paul _________________ Paul Clarke
MQGem Software
www.mqgem.com |
|
Back to top |
|
 |
venkata.silla4u |
Posted: Wed May 22, 2019 3:05 am Post subject: MQ destructive read/get |
|
|
Newbie
Joined: 21 May 2019 Posts: 2
|
I tried adding the No SYNCPOINT here, no luck.. still messages are sitting in the READ Queue which was dropped by the CICS program.
mqGMO.matchOptions = MQConstants.MQMO_MATCH_CORREL_ID;
mqGMO.options = MQConstants.MQGMO_WAIT + MQConstants.MQGMO_NO_SYNCPOINT; |
|
Back to top |
|
 |
Vitor |
Posted: Wed May 22, 2019 5:03 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
Use a try / catch block to ensure you're getting any errors MQ is throwing when it tries to commit the read.
It's best practice anyway; your code may be solid but any number of external factors can cause problems. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
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
|
|
|
|