[BUG] Lost service bus messages using ServiceBusReceiverClient
See original GitHub issueDescribe the bug We are not receiving messages from a service bus subscription that I have otherwise confirmed are being published.
Futhermore I’ve narrowed this down to one version change that introduces the problem (7.5.2 is fine, 7.6.0 is not) and a simple, seemingly unrelated change that works around the issue.
Exception or Stack Trace Error message seen:
'RELEASED' is not supported on a receiver opened in ReceiveMode.RECEIVE_AND_DELETE.
The stack trace that arrived there:
at com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient.updateDisposition(ServiceBusReceiverAsyncClient.java:1279)
at com.azure.messaging.servicebus.ServiceBusReceiverAsyncClient.release(ServiceBusReceiverAsyncClient.java:913)
at com.azure.messaging.servicebus.SynchronousMessageSubscriber.drainQueue(SynchronousMessageSubscriber.java:208)
at com.azure.messaging.servicebus.SynchronousMessageSubscriber.drain(SynchronousMessageSubscriber.java:157)
at com.azure.messaging.servicebus.SynchronousMessageSubscriber.hookOnNext(SynchronousMessageSubscriber.java:115)
at com.azure.messaging.servicebus.SynchronousMessageSubscriber.hookOnNext(SynchronousMessageSubscriber.java:24)
at reactor.core.publisher.BaseSubscriber.onNext(BaseSubscriber.java:160)
at reactor.core.publisher.FluxHandle$HandleSubscriber.onNext(FluxHandle.java:126)
at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onNext(FluxOnErrorResume.java:79)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122)
at reactor.core.publisher.FluxMap$MapSubscriber.onNext(FluxMap.java:122)
at com.azure.messaging.servicebus.implementation.ServiceBusReceiveLinkProcessor.drainQueue(ServiceBusReceiveLinkProcessor.java:478)
at com.azure.messaging.servicebus.implementation.ServiceBusReceiveLinkProcessor.drain(ServiceBusReceiveLinkProcessor.java:437)
at com.azure.messaging.servicebus.implementation.ServiceBusReceiveLinkProcessor.lambda$onNext$2(ServiceBusReceiveLinkProcessor.java:210)
To Reproduce Steps to reproduce the behaviour:
- During our tests we create a subscription to a topic to confirm messages have been published correctly by the application
- We then create a client
- Try and receive messages
- We should in our test always get 2 messages, however we often get 0 or 1 instead.
- Logs contain the following message once for each missing message:
- ‘RELEASED’ is not supported on a receiver opened in ReceiveMode.RECEIVE_AND_DELETE.
Code Snippet
var client = new ServiceBusClientBuilder()
.connectionString(primaryConnectionString)
.receiver()
.topicName(topic)
.subscriptionName(subscriptionName)
.receiveMode(ServiceBusReceiveMode.RECEIVE_AND_DELETE)
.prefetchCount(0)
.buildClient();
// Note two details: receive mode and the number in the prefetch count. The problem goes away if you change either (0 is actually
// the default even though it says it is 1 on the builder java doc).
var messages = client.receiveMessages(2, 10000);
Expected behavior We should have received 2 messages. Instead we get 0, 1 or 2, seemingly at random.
Setup (please complete the following information):
- OS: Tested on both MacOS and Ubuntu Linux
- IDE: IntelliJ and running via gradle in terminal
- Library/Libraries: confirmed in ‘com.azure:azure-messaging-servicebus:7.6.0’ and all newer. Not in 7.5.2.
- Java version: 17
- App Server/Environment: Netty
- Frameworks: Junit 5
Additional context I believe the problem was introduced during this change:
https://github.com/Azure/azure-sdk-for-java/commit/e7958563952c838313e0408efbcdccc191c145f1
Looking at the change you can see why the prefetch setting effects the outcome - the asyncClient.release
call is only made when prefetch is disabled.
Issue Analytics
- State:
- Created a year ago
- Comments:13 (8 by maintainers)
Top GitHub Comments
Hi @pjrharley , thank you for your report, I’m looking at this issue.
Hi @pjrharley , thank you for your reply. I’m going to close this issue, if you meet this issue again, you can reopen it, I’m glad to help you!