[BUG] Service Bus Receiver stops receiving messages from queues after Server Errors
See original GitHub issueDescribe the bug When there is Server Errors in Service Bus, which happen once or twice per week. The Service Bus queue receiver stops receiving the messages, while the queue sender can keep sending them.
The only way we can fix this is to restart the app.
Exception or Stack Trace This is one of the errors after the Server Errors:
{"az.sdk.message":"Non-retryable error occurred in AMQP receive link.","exception":"The service was unable to process the request; please retry the operation. For more information on exception types and proper exception handling, please refer to http://go.microsoft.com/fwlink/?LinkId=761101 TrackingId:ebae50e8a3044adf88825a821bf53108_G28, SystemTracker:gateway7, Timestamp:2022-04-26T02:03:16, errorContext[NAMESPACE: asavie-platform-servicebus-stg-eu-1.servicebus.windows.net. ERROR CONTEXT: N/A, PATH: my-queue-here, REFERENCE_ID: my-queue-here_7a1b06_1649943062396, LINK_CREDIT: 2]","linkName":"n/a","entityPath":"n/a"}
To Reproduce Create a receiver no matter if using the synchronous or the processor model and leave it running for a week receiving messages. Wait until there is Server Errors, shortly after that the Receiver stops receiving messages while the Sender can keep sending them.
The problem here is that not all the Server Errors cause this problem, but since they all arrive in bulk, one of them trigger the problem, here is a screenshot of the Server error that caused the problem:

On the top is this log occurrence, in the middle is the number of server errors and at the bottom is the messages in and out. You can see that is during the 4th server error that the app logs the error and stops receiving the messages. The yellow line is the received messages and the green line is the sent messages.
Code Snippet
this.serviceBusReceiver = new ServiceBusClientBuilder()
.connectionString(applicationProperties.getServiceBusQueueConnectionString())
.processor()
.queueName(applicationProperties.getServiceBusQueueName())
.processMessage(this::onMessage)
.processError(ServiceBusQueueReceiver::handleError)
.buildProcessorClient();
Expected behavior The Receiver should reconnect properly and keep receiving the messages.
Setup (please complete the following information):
- OS: Linux
- Library/Libraries: com.azure:azure-messaging-servicebus:7.7.0
- Java version: 11
- App Server/Environment: Tomcat
- Frameworks: Spring Boot
Additional context We have multiple clusters with the same setup pointing to multiple Service Bus namespaces configured exactly the same way. All of them have the same issue, as soon as there are server errors in service bus, the receiver stops receiving messages.
Information Checklist Kindly make sure that you have added all the following information above and checkoff the required fields otherwise we will treat the issuer as an incomplete report
- Bug Description Added
- Repro Steps Added
- Setup information Added
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:18 (6 by maintainers)
Top Related StackOverflow Question
Hi Quentin, you’re right that when using “ServiceBusAsyncReceiver” you’ll have to handle the case where the receiver instance bubble up a non-retriable error or exhaust retry. Like I mentioned, “error is a terminal event by reactive contract”.
Depending on how much your application logic is integrated with the Reactor framework, the code pattern for recovery you want to use may differ; if we start with a very simplified apporach, it will be -
Let me know how it goes.
If we want to go a more reactive way of recovery, then there is retryWhen operator
We got the same problem. Any news?