Removing Message from Queue only if user does some operation

messagemsmqpeekproperties

We are having MVC application which reads data from MSMQ.
We are trying to find out a way to read message from queue and remove it from queue only if user has done a successful operation on the queue.
The message should remain in the queue until user completes the processing, the message should not be available to anyone else until the user who is processing the message object has finished the operation.

Is there a property for a Message object to be set as Peeked which will not allow reading of this message again until ether it is put back into the queue or removed from the queue?

We are not sure if using MSMQ is a good idea in this case?

Best Answer

It sounds like you need to use your queue(s) in transactional mode. Then, your client can receive a message, process it, and then commit the transaction, at which point the message will be finally dequeued. While the transaction is active, however, other clients will not see the message -- it will be held in reserve until the transaction completes or is aborted.

This MSDN article has a decent overview of usage patterns for reliable messaging with MSMQ:

http://msdn.microsoft.com/en-us/library/ms978430.aspx

Related Topic