Azure / azure-sdk-for-java

This repository is for active development of the Azure SDK for Java. For consumers of the SDK we recommend visiting our public developer docs at https://docs.microsoft.com/java/azure/ or our versioned developer docs at https://azure.github.io/azure-sdk-for-java.
MIT License
2.25k stars 1.93k forks source link

How to configure @ServiceBusListener ServiceBusReceiveMode among Spring Message #38739

Open kensinzl opened 4 months ago

kensinzl commented 4 months ago

Query/Question

my question is how to configure the ServiceBusReceiveMode for the Java springboot if you use the annotation, eg: @ServiceBusListener

Setup (please complete the following information if applicable):

### Tasks
joshfree commented 4 months ago

@yiliuTo could you take a look?

/cc @Azure/azsdk-sb-java

Netyyyy commented 4 months ago

Hi @kensinzl Thank you for reporting this issue. We have received your submission and will take a look. We appreciate your input and will review this matter as soon as possible. Please feel free to provide any additional information or context that you think may be helpful. We'll keep you updated on the progress of our review.

kensinzl commented 2 months ago

Hey, is there any progress, seems no one take this issue to have a look

kensinzl commented 2 months ago

@yiliuTo @Netyyyy @joshfree any progress for this ticket? thanks

nikoladjuran commented 1 month ago

I'm stuck with a similar issue where I want to configure the @ServiceBusListener to use PEEK_LOOK and to enable sessions on the consumer as the subscription has sessions enabled. Properties like spring.cloud.azure.servicebus.processor.session-enabled=true spring.cloud.azure.servicebus.processor.receive-mode=peek_lock do not seem to work with the annotated listeners.

nikoladjuran commented 1 month ago

@kensinzl FYI: Managed to figure it out... Those properties don't configure the @ServiceBusListener but seem to be for other approaches like ServiceBusClient. I've managed to configure the listeners with the following bean declaration.

@Bean
public PropertiesSupplier<ConsumerIdentifier, ProcessorProperties> propertiesSupplier() {
    return key -> {
        var processorProperties = new ProcessorProperties();
        processorProperties.setEntityType(ServiceBusEntityType.TOPIC);
        processorProperties.setReceiveMode(ServiceBusReceiveMode.PEEK_LOCK);
        processorProperties.setSessionEnabled(Boolean.TRUE);

        return processorProperties;
    };
}
kensinzl commented 1 month ago

@nikoladjuran Hey man, thanks for the information.

I still use the @ServiceBusListener(Spring messaging) to monitor the service bus queue. If my understanding is correct, the @ServiceBusListener source code is using the default ServiceBusReceiveMode.PEEK_LOCK and also embed the commit to delete the message if successfully executed.

again, the document of azure is quite a mess, particularly the Java Azure SDK. Hopefully, I am on the right track.