Mark C.
Mark C.

Reputation: 6460

Why is the ApproximateMessageCount property on an Azure Storage queue nullable?

The title pretty much explains my question:

If there are no messages in the Storage Queue, why would it not just return 0, assuming we were able to get the queue reference and make a connection? Instead, it returns null.

Does it have to do with the fact that the message count is "approximate?" Curious, more than anything.

Upvotes: 15

Views: 3110

Answers (1)

Michael Roberson - MSFT
Michael Roberson - MSFT

Reputation: 1621

The approximate message count starts as null to indicate that it has not been initialized. After the first call to FetchAttributes, it is populated with the current value from the service. If there are no messages in the queue at this point then the value returned is zero.

Upvotes: 17

Related Questions