Reading data from MSMQ and marking it as read

We are using MSMQ to store the object. The client application (which is the asp.net UI) reads data from the queue. We have 2 cases which I think .Net MessageQueue does not directly support

Case 1: When an object is read from the queue. We need to do some processing on the object. If the processing fails (this happens if the user closes the browser), then we will lose the object, since it has already been read from the queue, and we have not completed processing. Is there a way in MSMQ to point to a specific event, return the object back to the queue.

Case 2: When an object is read in the form of a queue, how can we mark the object as read without removing it from the queue?

I've tried Message.BeginPeek which doesn't solve the problem.

+2


source to share


1 answer


You want to use transactional queues for this scenario. When you receive a message in a transaction, it will remain in the queue, but will not be available to anyone else. If you successfully process the message, you can commit the transaction, which will remove it from the queue. If processing fails, you simply abort the transaction and the message is available again to the next handler.



You will need a Receive method to receive a message from the transactional queue.

+2


source







All Articles