tags:

views:

250

answers:

1

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

Case 1: When the object is read from the queue. We need to do some processing on the object. If the processing fails (this will happen if the user closes the browser) then we loose the object since its already read from the queue and we have not completed the processing. Is there a way in MSMQ to specify on a certain event put the object back in the queue.

Case 2: When the object is read form the queue how can we mark the object as read without deleting it from the queue?

I have tried Message.BeginPeek which is not solving the issue.

+1  A: 

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

You'll need to use the Receive method in order to receive the message off the transactional queue.

bfallin