Reputation: 839
I am listening for messages from an IBM MQ using .Net. When it sees a message it removes the message from the queue automatically. I want to check the schema of the message first. If its not the correct schema I am looking for I want to keep it in the queue.
How do I alter the code to not automatically remove the message from the queue when a message is found?
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_FAIL_IF_QUIESCING;
IBM.WMQ.MQQueueManager mqManager = new IBM.WMQ.MQQueueManager(qmName);
MQQueue queue = mqManager.AccessQueue(queueName, openOptions);
MQGetMessageOptions gmo = new MQGetMessageOptions();
gmo.Options = MQC.MQGMO_FAIL_IF_QUIESCING | MQC.MQGMO_WAIT;
gmo.WaitInterval = MQC.MQWI_UNLIMITED;
queue.Get(message, gmo);
//Only remove message from the queue if a schema check of the message has passed
Upvotes: 0
Views: 1182
Reputation: 7506
It is far, far better to hand out queues like candy. If there are 5 different types of schemas that could land in the original queue then you should just use 5 queues.
i.e.
It will make for faster processing and you can have 1 listener for each queue.
Upvotes: 0
Reputation: 2636
You can browse the message to see if it is what you need and then do a GET if you determine it is. GET is destructive and removes message from a queue, browse is not destructive but lets you examine contents.
openOptions = MQC.MQOO_BROWSE // open queue for browsing
Upvotes: 2