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.35k stars 1.99k forks source link

[ServiceBus]where the complete function in JMS spring Service Bus SDK #18663

Closed Scarlettliuyc closed 3 years ago

Scarlettliuyc commented 3 years ago

Query/Question hi team , we found there is an lock expired error when using peek lock mode in JMS Spring Service bus SDK.

We tried to check the time in our system. @JmsListener(destination = "${service.bus.queueName}", containerFactory = "jmsListenerContainerFactory")

for receive message, we only spent less than 200ms in receive and send out email in our functions. However the default lock duration time is 30s,

Questions: where can we find the complete function in JMS spring Service Bus SDK. It confirmed have complete in any Encapsulation functions in the SDK . We want to check the complete time and extend the lock duration time based on the total time with receive and complete the message.

We are grateful for your reply.

Scarlettliuyc commented 3 years ago

hi team, here add more information: issue definition: The Service Bus JMS program get lock expired error. It use Peeklock mode, and set 30s for lock duration. Max message count is 1 investigation done: As the issue always happen in the client side, it's not the Service Bus server issue, and checked for the service bus namespace, it didn't have KPI drops or errors that time. When receive the message, it also send a emails out. We already test for the time duration before send or finish send email, it spent less than 1 s to finish it. But we cannot find where is the complete function of this JMS spring framework.

Reproducing steps: Set Max Message to 1, and lock duration to 30, it would have chance to got the "lock expired error"

SDK version:

azure-servicebus-jms-spring-boot-starter
        <version>2.3.5</version>
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.0.1.RELEASE</version>
    <relativePath /> <!-- lookup parent from repository -->
</parent>
central Maven Repository default https://repo1.maven.org/maven2/ false

Code: receive message: private EmailService emailService;

@JmsListener(destination = "${service.bus.queueName}", containerFactory = "jmsListenerContainerFactory")
public void receiveMessage(String msg) {
    TemplateVO template = JSONObject.toJavaObject(JSON.parseObject(msg), TemplateVO.class);
    log.info("Received message: {}", template);
    emailService.sendTemplateEmail(template);
}

Ask: where can we find the complete function to test the complete time? searched for acknowledge or complete cannot find it ?

thanks

joshfree commented 3 years ago

@hemanttanwar could you please assist?

hemanttanwar commented 3 years ago

@Scarlettliuyc Thank You for the query. I was able to run the sample at https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/spring/azure-spring-boot-samples/azure-spring-boot-sample-servicebus-jms-queue . I also added some delay in receiving side but I did not see the issue.

We are still looking into it and will update you.

Scarlettliuyc commented 3 years ago

thanks @hemanttanwar could you please tell me where can we find the complete function? I checked it should have completed. we are trying to find which part spent longer time and cause lock expired error

backwind1233 commented 3 years ago

hi @Scarlettliuyc, do you mean that you want to know where the @JmsListener be called? I think you can check and debug the method org.springframework.jms.listener.DefaultMessageListenerContainer.AsyncMessageListenerInvoker#executeOngoingLoop inside the method body, it called invokeListener() where the listener be called. image

Scarlettliuyc commented 3 years ago

thanks @backwind1233 as I know service bus message should receive and complete message, I know here it's to receive message, is that @JmsListener(destination = "${service.bus.queueName}", containerFactory = "jmsListenerContainerFactory")

is this org.springframework.jms.listener.DefaultMessageListenerContainer.AsyncMessageListenerInvoker#executeOngoingLoop can complete the message, thank you

Scarlettliuyc commented 3 years ago

hi team, for the receive mode When using the "azure-servicebus-jms-spring-boot-starter" package, did not set the receive mode, and used the default mode. When change to use "azure-messaging-servicebus" package, set the receive mode to RECEIVE_AND_DELETE.

could you please tell me any more information you needed?