Retrieving messages off a Queue
Reading a message off the queue may be requested using one of two modes. PeekLock
, which is the default mode, reads the message of the queue and places a lock on the read message. This makes the message invisible to other consumers of the Queue. The message will reappear on the Queue if the consumer does not issue a Complete
command within the specified VisibilityTimeout
period. The message can also reappear if the consumer calls the Abandon
method. This type of processing is ideal for when guaranteed processing of a message is mandatory.
The second option is ReceiveAndDelete
mode. This is when, once the message is read, it will immediately be deleted from the Queue. This ensures that the message will get processed once only and is processed in FIFO order. However, there is a risk of the message getting lost if the process that consumed the message hangs.
To ensure your message is idempotent, there are several strategies that may be adopted:
Setting the
VisibilityTimeout...