Skip to content

[BUG] ServiceBus Messages Completing with AutoComplete Disabled #46980

@robsonkades

Description

@robsonkades

Describe the bug
Although AutoComplete is disabled, when completing the message I am getting error that the message is already completed

Exception or Stack Trace

Sending a message to the queue.
2025-10-12T20:16:51.307-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [  restartedMain] c.a.m.s.ServiceBusClientBuilder          : # of open clients using shared connection cache: 1
2025-10-12T20:16:51.332-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [  restartedMain] c.a.c.a.i.ReactorConnectionCache         : {"az.sdk.message":"Waiting to connect and active.","entityPath":"N/A","connectionId":"MF_4afe68_1760311011330"}
2025-10-12T20:16:51.332-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [  restartedMain] c.a.c.a.i.ReactorConnection              : {"az.sdk.message":"Creating and starting connection.","connectionId":"MF_4afe68_1760311011330","hostName":"robsonkades.servicebus.windows.net","port":5671}
2025-10-12T20:16:51.332-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [  restartedMain] c.a.c.a.implementation.ReactorExecutor   : {"az.sdk.message":"Starting reactor.","connectionId":"MF_4afe68_1760311011330"}
2025-10-12T20:16:51.334-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.handler.ConnectionHandler      : {"az.sdk.message":"onConnectionInit","connectionId":"MF_4afe68_1760311011330","hostName":"robsonkades.servicebus.windows.net","namespace":"robsonkades.servicebus.windows.net"}
2025-10-12T20:16:51.334-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.handler.ReactorHandler         : {"az.sdk.message":"reactor.onReactorInit","connectionId":"MF_4afe68_1760311011330"}
2025-10-12T20:16:51.334-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.handler.ConnectionHandler      : {"az.sdk.message":"onConnectionLocalOpen","connectionId":"MF_4afe68_1760311011330","hostName":"robsonkades.servicebus.windows.net"}
2025-10-12T20:16:51.334-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.handler.ConnectionHandler      : {"az.sdk.message":"onConnectionBound","connectionId":"MF_4afe68_1760311011330","hostName":"robsonkades.servicebus.windows.net","peerDetails":"robsonkades.servicebus.windows.net:5671"}
2025-10-12T20:16:51.518-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.handler.ConnectionHandler      : {"az.sdk.message":"onConnectionRemoteOpen","connectionId":"MF_dc3465_1760311010738","hostName":"robsonkades.servicebus.windows.net","remoteContainer":"aa8ebaf5270549f49f896b57ebc899d6_G4"}
2025-10-12T20:16:51.520-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.ReactorConnectionCache         : {"az.sdk.message":"Emitting the new active connection.","entityPath":"N/A","connectionId":"MF_dc3465_1760311010738"}
2025-10-12T20:16:51.527-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.ReactorConnection              : {"az.sdk.message":"session local open scheduled.","connectionId":"MF_dc3465_1760311010738","sessionName":"task","sessionId":"H_185178_1760311011523"}
2025-10-12T20:16:51.677-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.handler.SessionHandler         : {"az.sdk.message":"onSessionRemoteOpen","connectionId":"MF_dc3465_1760311010738","sessionName":"task","sessionId":"H_185178_1760311011523","sessionIncCapacity":0,"sessionOutgoingWindow":2147483647}
2025-10-12T20:16:51.681-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.ReactorConnection              : {"az.sdk.message":"Setting CBS channel.","connectionId":"MF_dc3465_1760311010738"}
2025-10-12T20:16:51.685-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.ReactorConnection              : {"az.sdk.message":"session local open scheduled.","connectionId":"MF_dc3465_1760311010738","sessionName":"cbs-session","sessionId":"H_dfcb32_1760311011684"}
2025-10-12T20:16:51.841-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.handler.SessionHandler         : {"az.sdk.message":"onSessionRemoteOpen","connectionId":"MF_dc3465_1760311010738","sessionName":"cbs-session","sessionId":"H_dfcb32_1760311011684","sessionIncCapacity":0,"sessionOutgoingWindow":2147483647}
2025-10-12T20:16:51.849-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.RequestResponseChannelCache    : {"az.sdk.message":"Waiting for channel to active.","connectionId":"MF_dc3465_1760311010738","linkName":"cbs"}
2025-10-12T20:16:51.956-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.handler.ConnectionHandler      : {"az.sdk.message":"onConnectionRemoteOpen","connectionId":"MF_4afe68_1760311011330","hostName":"robsonkades.servicebus.windows.net","remoteContainer":"0231d45043be477799640bc1906815b2_G0"}
2025-10-12T20:16:51.956-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.ReactorConnectionCache         : {"az.sdk.message":"Emitting the new active connection.","entityPath":"N/A","connectionId":"MF_4afe68_1760311011330"}
2025-10-12T20:16:51.958-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.ReactorConnection              : {"az.sdk.message":"session local open scheduled.","connectionId":"MF_4afe68_1760311011330","sessionName":"task","sessionId":"H_d34a78_1760311011957"}
2025-10-12T20:16:52.000-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.handler.SendLinkHandler        : {"az.sdk.message":"onLinkRemoteOpen","connectionId":"MF_dc3465_1760311010738","linkName":"cbs:sender","entityPath":"$cbs","remoteTarget":"Target{address='$cbs', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, capabilities=null}"}
2025-10-12T20:16:52.002-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.RequestResponseChannelCache    : {"az.sdk.message":"Emitting the new active channel.","connectionId":"MF_dc3465_1760311010738","linkName":"cbs"}
2025-10-12T20:16:52.004-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.handler.ReceiveLinkHandler2    : {"az.sdk.message":"onLinkRemoteOpen","connectionId":"MF_dc3465_1760311010738","entityPath":"$cbs","linkName":"cbs:receiver","remoteSource":"Source{address='$cbs', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, distributionMode=null, filter=null, defaultOutcome=null, outcomes=null, capabilities=null}"}
2025-10-12T20:16:52.108-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.handler.SessionHandler         : {"az.sdk.message":"onSessionRemoteOpen","connectionId":"MF_4afe68_1760311011330","sessionName":"task","sessionId":"H_d34a78_1760311011957","sessionIncCapacity":0,"sessionOutgoingWindow":2147483647}
2025-10-12T20:16:52.109-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.ReactorConnection              : {"az.sdk.message":"Setting CBS channel.","connectionId":"MF_4afe68_1760311011330"}
2025-10-12T20:16:52.110-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.ReactorConnection              : {"az.sdk.message":"session local open scheduled.","connectionId":"MF_4afe68_1760311011330","sessionName":"cbs-session","sessionId":"H_305dd2_1760311012110"}
2025-10-12T20:16:52.160-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.ActiveClientTokenManager       : {"az.sdk.message":"Scheduling refresh token task.","scopes":"amqp://robsonkades.servicebus.windows.net/task"}
2025-10-12T20:16:52.162-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.implementation.ReactorSession    : {"az.sdk.message":"Creating a new receiver link.","connectionId":"MF_dc3465_1760311010738","sessionName":"task","sessionId":"H_185178_1760311011523","linkName":"task_92203b_1760311010727"}
2025-10-12T20:16:52.167-03:00  WARN 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.amqp.implementation.MessageFlux    : {"az.sdk.message":"Setting next mediator and waiting for activation.","messageFlux":"mf_5c3db9_1760311010730","connectionId":"MF_dc3465_1760311010738","linkName":"task_92203b_1760311010727","entityPath":"task"}
2025-10-12T20:16:52.259-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.handler.SessionHandler         : {"az.sdk.message":"onSessionRemoteOpen","connectionId":"MF_4afe68_1760311011330","sessionName":"cbs-session","sessionId":"H_305dd2_1760311012110","sessionIncCapacity":0,"sessionOutgoingWindow":2147483647}
2025-10-12T20:16:52.260-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.RequestResponseChannelCache    : {"az.sdk.message":"Waiting for channel to active.","connectionId":"MF_4afe68_1760311011330","linkName":"cbs"}
2025-10-12T20:16:52.324-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-1] c.a.c.a.i.handler.ReceiveLinkHandler2    : {"az.sdk.message":"onLinkRemoteOpen","connectionId":"MF_dc3465_1760311010738","entityPath":"task","linkName":"task_92203b_1760311010727","remoteSource":"Source{address='task', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, distributionMode=null, filter=null, defaultOutcome=null, outcomes=null, capabilities=null}"}
2025-10-12T20:16:52.325-03:00  WARN 19716 --- [spring-azure-servicebus-bug] [ receiverPump-1] c.a.c.amqp.implementation.MessageFlux    : {"az.sdk.message":"The mediator is active.","messageFlux":"mf_5c3db9_1760311010730","connectionId":"MF_dc3465_1760311010738","linkName":"task_92203b_1760311010727","entityPath":"task"}
2025-10-12T20:16:52.419-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.handler.SendLinkHandler        : {"az.sdk.message":"onLinkRemoteOpen","connectionId":"MF_4afe68_1760311011330","linkName":"cbs:sender","entityPath":"$cbs","remoteTarget":"Target{address='$cbs', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, capabilities=null}"}
2025-10-12T20:16:52.419-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.RequestResponseChannelCache    : {"az.sdk.message":"Emitting the new active channel.","connectionId":"MF_4afe68_1760311011330","linkName":"cbs"}
2025-10-12T20:16:52.419-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.handler.ReceiveLinkHandler2    : {"az.sdk.message":"onLinkRemoteOpen","connectionId":"MF_4afe68_1760311011330","entityPath":"$cbs","linkName":"cbs:receiver","remoteSource":"Source{address='$cbs', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, distributionMode=null, filter=null, defaultOutcome=null, outcomes=null, capabilities=null}"}
2025-10-12T20:16:52.736-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.ActiveClientTokenManager       : {"az.sdk.message":"Scheduling refresh token task.","scopes":"amqp://robsonkades.servicebus.windows.net/task"}
2025-10-12T20:16:52.737-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.implementation.ReactorSession    : {"az.sdk.message":"Creating a new send link.","connectionId":"MF_4afe68_1760311011330","sessionName":"task","sessionId":"H_d34a78_1760311011957","linkName":"tasktask"}
2025-10-12T20:16:52.904-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.m.s.ServiceBusSenderAsyncClient      : {"az.sdk.message":"Sending batch.","entityPath":"task","batchSize":1}
2025-10-12T20:16:52.907-03:00  INFO 19716 --- [spring-azure-servicebus-bug] [ctor-executor-2] c.a.c.a.i.handler.SendLinkHandler        : {"az.sdk.message":"onLinkRemoteOpen","connectionId":"MF_4afe68_1760311011330","linkName":"tasktask","entityPath":"task","remoteTarget":"Target{address='task', durable=NONE, expiryPolicy=SESSION_END, timeout=0, dynamic=false, dynamicNodeProperties=null, capabilities=null}"}
**2025-10-12T20:16:53.286-03:00 ERROR 19716 --- [spring-azure-servicebus-bug] [ receiverPump-2] c.a.m.s.ServiceBusReceiverAsyncClient    : The message has either been deleted or already settled.**

To Reproduce

  • Create a queue.
  • Push message to the queue.
  • Complete the process with the complete() method of ServiceBusReceivedMessageContext.

Code Snippet

spring.cloud.azure.servicebus.entity-type=queue
spring.cloud.azure.servicebus.consumer.receive-mode=peek_lock
spring.cloud.azure.servicebus.consumer.auto-complete=false
spring.cloud.azure.servicebus.processor.auto-complete=false
spring.cloud.azure.servicebus.processor.receive-mode=peek_lock
@SpringBootApplication
@EnableAzureMessaging
public class SpringAzureServicebusBugApplication {
    private static final String QUEUE_NAME = "task";

    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = SpringApplication.run(SpringAzureServicebusBugApplication.class);
        ServiceBusTemplate serviceBusTemplate = applicationContext.getBean(ServiceBusTemplate.class);
        System.out.println("Sending a message to the queue.");
        serviceBusTemplate.sendAsync(QUEUE_NAME, MessageBuilder.withPayload("Hello world").build()).subscribe();
    }
}
@Service
public class ConsumerExample {

    @ServiceBusListener(destination = "task")
    public void onMessage(String message, MessageHeaders headers) {
        ServiceBusReceivedMessageContext context = headers.get(ServiceBusMessageHeaders.RECEIVED_MESSAGE_CONTEXT, ServiceBusReceivedMessageContext.class);
        context.complete();
    }
}

pomx.xml

    <properties>
        <java.version>21</java.version>
        <spring-cloud-azure.version>6.0.0</spring-cloud-azure.version>
    </properties>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.azure.spring</groupId>
                <artifactId>spring-cloud-azure-dependencies</artifactId>
                <version>${spring-cloud-azure.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.azure.spring</groupId>
            <artifactId>spring-cloud-azure-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>com.azure.spring</groupId>
            <artifactId>spring-messaging-azure-servicebus</artifactId>
        </dependency>
</dependencies>

Expected behavior
Should be completed without any error

Setup (please complete the following information):

  • OS: [Win]
  • IDE: [IntelliJ]
  • Library/Libraries: [spring-messaging-azure-servicebu:6.0.0]
  • Java version: [21]
  • App Server/Environment: [Tomcat]
  • Frameworks: [Spring Boot]

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

Metadata

Metadata

Labels

ServiceThis issue points to a problem in the service.Service BusbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions