I have a requirement to get just a specific message from a queue based on its correlation ID.
Is there a way where we can get a message for the corresponding correlation ID and remove only that message from the queue without deleting the others.
The options which I have tried they retrieve the message but removing the other messages from the queue as well while finding my message
I have used the following openOptions in accessQueue method while browsing the queue
MQC.MQOQ_INPUT_SHARED | MQC.MQOO_FAIL_IF_QUIESCING | MQC_MQOO_INQUIRE | MQC.MQOOBROWSE
And the following options to get the message
String correlation ID = <correlationID>
MQMessage respMessage = new MQMessage();
respMessage.correlationId = correlation ID.getBytes();
MQGetMessageOptions msg = new MqGetMessageOptions();
msg.options = MQC.MQGMO_NO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING + MQC.MQGMO_CONVERT + MQC.MQGMO_BROWSE_NEXT
msg.matchOptions = MQC.MQMO_MATCH_MSG_ID
msg.waitInterval = 2000;
queue.get(respMessage, msg);