Instead of rolling back the read operation, you should update the message and reinstall it.
The first thing you need to do is create an unsuccessful check queue for messages that you do not want to process again. (Itβs useful to keep messages looking for problems, and the queue is a natural place.)
Further, if you want to retry only once, you can write it to the retry queue and change the verification process so that it sends failures coming from the retry queue to the failed verification queue.
If you want to retest more than once, you must change the message format to include the number of attempts and increase this number each time the process reorders the message.
Once the message reaches the maximum allowed attempts, your process may send it to the failed verification queue.
In MSMQ, you donβt have to change the format of the message: you can use Message.Extension to store the number of attempts, although it usually frowned - as this property documentation says: "If possible, you should include the message data in the Message body property, and not an Extension property. "
source share