Skip to content

[FEATURE REQUEST] Peek-Lock mode on sessionful subscriptions with custom session idle timeout #44414

@pboschmann

Description

@pboschmann

Query/Question
Hello and thank you for your time.
I am working on an integration of a Spring Boot project with the Azure Service Bus. Is it possible at all to create a message consumer in peek-lock mode for sessionful subscriptions using the @ServiceBusListener annotation with custom session idle timeout or am I simply overlooking something mundane?

Example:

@ServiceBusListener(destination = "${spring.cloud.azure.servicebus.entity-name}", group = "${spring.cloud.azure.servicebus.processor.subscription-name}")
@Override
public void listen(final String input) {
    log.debug("Received {}", input);
}

When I subscribe on a sessionfull subscription using the code above I get this error (on non sessionfull subscriptions the receiver is created and consumes messages just fine):
It is not possible for an entity that requires sessions to create a non-sessionful message receiver.
I used the following application.properties (also tried the processor prefix instead of consumer without luck). As you can see the session-enabled property is set to true, but the SDK instantiates a non-sessionful reicever.

spring.cloud.azure.servicebus.enabled=true
spring.cloud.azure.servicebus.domain-name=...
spring.cloud.azure.servicebus.namespace=...
spring.cloud.azure.servicebus.connection-string=Endpoint=...
spring.cloud.azure.servicebus.entity-type=topic
spring.cloud.azure.servicebus.entity-name=...
spring.cloud.azure.servicebus.consumer.subscription-name=...
spring.cloud.azure.servicebus.consumer.session-enabled=true
spring.cloud.azure.servicebus.consumer.auto-complete=true
spring.cloud.azure.servicebus.consumer.receive-mode=peek_lock

I was able to create a workaround by implementing a custom CustomServiceBusMessageListenerContainerFactory where I set the properties by myself. In this case messages will be consumed but I don't know how I can manipulate the session idle timeout. The value for "message lock duration" on the subscription itself seems to be completely ignored – I setup a value of 8 seconds, but according to logs the timeout occurs after 1 minute
As far as I understand this possibility was implemented in MR 34700 but it seems to me it works only with the fluent API.

Why is this not a Bug or a feature Request?
Service Bus and the Java SDK make the impression of mature products, after tinkering for weeks I just hope that I overlook something.

Setup (please complete the following information if applicable):

  • OS: macOS 13.2
  • openJDK 21
  • IDE: IntelliJ
  • Library/Libraries: relevant snippets from pom.xml below
<spring-cloud.version>2024.0.0</spring-cloud.version>
<com.azure.spring.cloud.version>5.20.0</com.azure.spring.cloud.version>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>3.4.2</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>

<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>


<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>com.azure.spring</groupId>
            <artifactId>spring-cloud-azure-dependencies</artifactId>
            <version>5.20.0</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

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

  • Query Added
  • Setup information Added

Metadata

Metadata

Assignees

Labels

ClientThis issue points to a problem in the data-plane of the library.azure-springAll azure-spring related issuescustomer-reportedIssues that are reported by GitHub users external to the Azure organization.feature-requestThis issue requires a new behavior in the product in order be resolved.

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions