Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove a JMS message from MQ Queue using JMSMessageID

Tags:

java

jms

ibm-mq

mq

Is there a way to remove a JMS message from an IBM MQ Queue using JMSMessageId ina Java application(not using tools)? Also are such operations vendor-specific?

Looked through the API for receive operations which are used to remove messages, but for removing specific messages, do we need to filter using MessageSelector and remove appropriately, or is there a more simple way? [checking for any available method which can be directly used]

Can you please provide tutorials/examples [can be links too] to show the API usage for such operations?

like image 863
ram Avatar asked May 27 '26 13:05

ram


1 Answers

When you use JMSMessageID as the only message property in a selector, WMQ optimizes the lookup to be the same as a native WMQ API get by MQMD.MessageID which is an indexed field in the queue. Please see the JMS Message Selection topic for more details.

QueueReceiver rcvr = sess.createReceiver(inputQ, "JMSCorrelationID = '"+msgId+"'")

You can also do the same thing using native WMQ API calls using Java native code. You would do a normal GET operation but specify the message ID in the MQMD structure.

myMsg.messageId = someMsgID; 
MQGetMessageOptions gmo = new MQGetMessageOptions(); 
myQueue.get(myMsg, gmo);
like image 164
T.Rob Avatar answered May 30 '26 15:05

T.Rob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!