[QUERY] In what circumstances ReceiveMessagesAsync can return empty collection #48396
Labels
Client
This issue points to a problem in the data-plane of the library.
customer-reported
Issues that are reported by GitHub users external to the Azure organization.
issue-addressed
Workflow: The Azure SDK team believes it to be addressed and ready to close.
question
The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Service Bus
Library name and version
Azure.Messaging.ServiceBus 7.17.5
Query/Question
Our application receives messages using the SDK, but we need to use a batching solution due to a dependency on a database that prefers batch inserts. We collect messages for up to 10 minutes or until a batch size is exceeded.
The ServiceBus is in the Standard Tier, and the region where the ServiceBus and application are located is the same (though they are in different resource groups).
To receive messages, we connect to a topic with a defined subscription. The traffic is quite low (around a few dozen messages per minute). The lock duration for the subscription is set to the default value of
1 minute
.What is our scenario?
An ASP.NET Core application creates a ServiceBus client using ASP.NET IoC. A client and receiver are created as singletons.
and the receiver:
Basic assumptions:
PrefetchCount
is set to 0 to avoid locking messages. This prevents messages from being moved to the DLQ. Messages are collected for 10 minutes, so we need to avoid locking messages if traffic is low.Over the course of 3 hours, 3-5 messages (depending on the region) were read, even though the queue had a few dozen messages. Surprisingly, most of the time
ReceiveMessagesAsync()
returned an empty collection. We noticed that the dead-letter queue received those messages, butReceiveMessagesAsync()
did not throw an exception (no exception was caught). I found that the ServiceBus metrics showed user errors during the test period (I can find anything in logs).The empty collection is returned even when
ReceiveMessagesAsync()
is executed multiple times, repeatedly, one after another, without a break.ReceiveMessagesAsync()
, or is there a different solution for this? According to the documentation, this locks messages, so how can we prevent lock expiration whenReceiveMessagesAsync()
is not executed immediately?Environment
It will be hard to get because this is asp.net core app hosted on an AppService and I have no access to check details.
.Net 8.0
IDE - Rider or VS 17.13.1
The text was updated successfully, but these errors were encountered: