MQ Series messages browse and delete

V

Vadim

Hi,

I am writing an MQ client that should get messages from MQ Queue one
by one and then delete it in case of successful processing.
As documented in MQ Series Programming Guide a queue should be opened
for browsing and removing. For browsing an option
MQGMO_BROWSE_FIRST or MQGMO_BROWSE_NEXT should be used and for
deleting MQGMO_BROWSE_MSG_UNDER_CURSOR.
Browsing works fine for me but delete does not - all messages remain
in a queue.

Thanks

Following is a code fragment:

..................
try {
mQMgr = new MQQueueManager(remoteQManager);
int openInputOptions = MQC.MQOO_FAIL_IF_QUIESCING |
MQC.MQOO_INPUT_SHARED | MQC.MQOO_BROWSE;

outputQueue=mQMgr.accessQueue(remoteQueue, openInputOptions);
MQMessage retrievedMessage = new MQMessage();
MQGetMessageOptions gmo=new MQGetMessageOptions();
gmo.options=MQC.MQGMO_WAIT | MQC.MQGMO_BROWSE_FIRST;
gmo.matchOptions=MQC.MQMO_NONE;
gmo.waitInterval=10000;

while(true) {
if(c>0) { gmo.options = MQC.MQGMO_WAIT |
MQC.MQGMO_BROWSE_NEXT; }
outputQueue.get(retrievedMessage, gmo);
msg=retrievedMessage.readString(retrievedMessage.getMessageLength());
System.out.println("************************ message "+c+"
********************** " + retrievedMessage.persistence);
System.out.println("RETRIEVED MESSAGE: "+msg);
System.out.println("REMOVING
..................................");
gmo.options = MQC.MQGMO_WAIT |
MQC.MQGMO_BROWSE_MSG_UNDER_CURSOR;
outputQueue.get(retrievedMessage, gmo);

c++;
}
} catch (MQException mqe) {
if(mqe.reasonCode == mqe.MQRC_NO_MSG_AVAILABLE) {
System.out.println("NO MORE MESSAGES AVAILABLE, RETRIEVED
"+c);
return;
}
mqe.printStackTrace();
} catch (java.io.IOException ioe) {
ioe.printStackTrace(System.out);
return;
} finally {
try {
System.out.println("CLOSING A QUEUE & MANAGER");
if(outputQueue != null) { outputQueue.close(); }
if(mQMgr != null) { mQMgr.disconnect(); }
}
catch (MQException ex) {
ex.printStackTrace();
}
}
 
Joined
Feb 12, 2008
Messages
1
Reaction score
0
the correct syntax

use the followin lines

System.out.println("REMOVING..................................");
getMessageOptions.options =MQC.MQGMO_MSG_UNDER_CURSOR;


instead of

System.out.println("REMOVING..................................");
getMessageOptions.options =MQC.MQGMO_BROWSER_MSG_UNDER_CURSOR;


K.Nisha
 
Joined
Apr 8, 2009
Messages
9
Reaction score
0
Sending Auto Acnowledgements to MQ

Nisha,
The way to delete the message after downloading is useful. Similarly I need to send Auto Acknowledgements for every downloaded message. I could not fifure out which is that property from the documentation.

Please let me know if you are aware how to achieve it.

Thanks,
Raghu.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top