The only reason I can think of is if you have received()
the message but did not call complete()
or abandon()
. In this case the message is "hidden" for a specific length of time (default is 30 seconds). During this time, your message count would be positive even though you cannot receive any messages.
When 30 seconds (the default) elapses, the messages become visible and you may receive()
them again. Note that the .DeliveryCount
property is incremented every time you receive the message until it reaches 10 (the default) and the message is dumped into the dead-letter sub queue.
Be sure to always call complete()
on any message you have processed. Call abandon()
if you want it to be immediately available in the queue for another worker to process. Also check the DeliveryCount
property to be sure you are not processing a message twice. (This can happen if you take a long time processing a message before calling complete()
and by then the lock has been released.)