azure-docs icon indicating copy to clipboard operation
azure-docs copied to clipboard

Message sequence number and enqueued time in exceptional scenarios

Open adeliab opened this issue 2 years ago • 3 comments

I would like some explanation on what happens to the sequence number when a message is abandoned or when a message is processed and the consumer throws an exception or the consumer is killed. Are they going to stay the same or updated? What happens in session based messaging?


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

adeliab avatar Aug 12 '22 07:08 adeliab

@adeliab Thanks for reaching out. The sequence number will only be changed once the message state changes to Active from scheduled state as documented. For any other scenario there is no change to the sequence number.

The SequenceNumber for a scheduled message is only valid while the message is in this state. As the message transitions to the active state, the message is appended to the queue as if had been enqueued at the current instant, which includes assigning a new SequenceNumber.

when a message is abandoned or when a message is processed and the consumer throws an exception or the consumer is killed. Are they going to stay the same or updated? What happens in session based messaging? SequenceNumber remains the same if your consumer abandoned the message/throws any exception then only the delivery count on the message increases by one every time your client is not able to consume that message. When you Deferred the message then you should be using the SequenceNumber to retrieve the deferred message.

Feel free to get back to me if you have any further queries or concerns.

MayankBargali-MSFT avatar Aug 12 '22 12:08 MayankBargali-MSFT

@adeliab Just following up here. Hope my previous comment clears things up.

MayankBargali-MSFT avatar Aug 16 '22 04:08 MayankBargali-MSFT

@MayankBargali-MSFT thanks for the clarification. So in terms of 'normal' (non scheduled messages), the sequence number stays the same. Only in the scenario of scheduled messages, the sequence number gets updated when a message changes state from scheduled to active. Am I understanding it correctly?

adeliab avatar Aug 16 '22 18:08 adeliab

@adeliab Yes, your understanding is correct.

We will now proceed to close this thread. If there are further questions regarding this matter, please reopen it and we will gladly continue the discussion.

MayankBargali-MSFT avatar Aug 18 '22 02:08 MayankBargali-MSFT