azure-sdk-for-java: [BUG] Non recoverable JMS connection caused by: java.lang.NullPointerException: null

Describe the bug Consumer implemented with spring-cloud-azure-starter-servicebus-jms loses the JMS connection and is not able to recover it.

Exception or Stack Trace The stack trace below shows that the connection is lost after or while processing the 31st message. Attempts to recover the connection can be seen with the message: Encountered a JMSException - resetting the underlying JMS Connection.

run_10011log.txt

On the 10th attempt the connection is not recovered and the consumer becomes stale. The only way to resume the consumption of messages is to stop the app and start it again.

To Reproduce

  1. Create a premium Azure Service Bus
  2. Load more than a thousand messages to a queue
  3. Consume messages with a spring boot app which connects with the version 4.3.0 of the spring-cloud-azure-starter-servicebus-jms deployed in a network outside Azure.

Code Snippet This is not identifiable as logs only report a cause of null.

Expected behavior The expected behaviour is that the process for resetting the underlying JMS connection eventually succeeds.

Screenshots If applicable, add screenshots to help explain your problem.

Setup (please complete the following information):

  • OS: Linux
  • IDE: n/a
  • Library/Libraries: com.azure.spring:spring-cloud-azure-starter-servicebus-jms:4.3.0 with Spring boot version 2.6.9 and Apache camel version 2.25.2
  • Java version: 8
  • App Server/Environment: Oracle Weblogic
  • Frameworks: Spring Boot, Apache Camel

I do not suspect a dependency version mismatch. I nevertheless provide the effective pom which includes all transitive dependencies: effective-pom.xml.txt

Additional context The capacity was increased at the Azure Service Bus level to 8 MU but it did not affect the behaviour of not recovering the JMS connection. It still failed after a few hundred messages were received.

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

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 19 (7 by maintainers)

Most upvoted comments

Dear @fangjian0423 ,

Indeed by creating separate transaction managers:

  • one for JMS transactions
  • one for the database transactions

I was able to process successfully 100,00 messages without a loss or errors using a standard (i.e. not premium) Azure ServiceBus resource. Note that:

  • I excluded the dependency on Apache Camel as its spring boot starter was not coping with two transaction managers. This dependency could be re-instated after finding the correct way to configure Camel without the auto-config.
  • I had to wrap all database operations behind a single façade. This was easy to do in this small PoC but could be very un-natural in a larger project.

To conclude, this issue can be closed. As a take-away it would be beneficial to the community to have guidance on how to approach the use case of processing messages while performing a transaction with a database.

Kind regards

Hi @adelinor , thanks for the detailed information. The test I used is a pure spring-jms application without camel jms since both camel-jms and Azure Service Bus JMS starter relys on the connection /listener container/transaction-management implementation from spring-jms, and here is the application I use. And for spring-jms, it by default configure the transacted session when no transaction manager is found, thus in my test I didn’t specifically configure the transaction.

However, I found that when using different ways for cross-entity transaction of spring-jms, it behaves differently of using JmsTemplate or @SendTo annotation, when using @SendTo, it will encounter the same error of Local transactions cannot span multiple top-level entities such as queue or topic. as what you have observed with camel, while when using JmsTemplate, it works normally. Thus I am reading the spring-jms code to understand the reason, and also plan to compare spring-jms with pure Qpid JMS implemenation about the transacted-session to see if can get more insights. And communication about spring-jms transacted session is welcome.

Dear @yiliuTo , Many thanks for coming back on this issue. The project I use is the following: camel-jms-calculator.zip