question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Lost service bus messages using ServiceBusReceiverClient

See original GitHub issue

Describe 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:closed
  • Created a year ago
  • Comments:13 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
ZejiaJiangcommented, Sep 13, 2022

Hi @pjrharley , thank you for your report, I’m looking at this issue.

0reactions
ZejiaJiangcommented, Nov 23, 2022

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting guide for Azure Service Bus - Microsoft Learn
This article provides troubleshooting tips and recommendations for a few issues that you may see when using Azure Service Bus.
Read more >
Overview (Azure SDK for Java Reference Documentation) - NET
Data is transferred between different applications and services using messages. If you would like to know more about Azure Service Bus, you may...
Read more >
Azure Messaging Service Bus Error: Illegal connection string ...
Endpoint=sb://foo.servicebus.windows.net/; SharedAccessSignature=<sas-token>;. Can you try creating a connection string using this? Otherwise, ...
Read more >
com.azure.messaging.servicebus.ServiceBusReceiverClient ...
ServiceBusReceiverClient maven / gradle build tool code. ... Libraries built on Microsoft Azure Service Bus ... {@code null} if there is no session....
Read more >
Azure Service Bus and its Complete Overview | Serverless360
With exceptional ingress rates, it can take on many incoming messages storing those internally offering no queue semantics. While it might sound like...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found