How to connect a Springboot app to an Azure SB with multiple subscriptions (with same name) across different topics

Kikrigen 0 Reputation points
2023-01-20T00:37:58.8733333+00:00

Hello All,

Problem: Getting an error when connecting to 2 different subscriptions with the same name across 2 different topics.

Details:

I have a Controller in a Springboot app connecting to an Azure Service Bus using JMSListeners.

Method 1:

@JmsListener(destination = "${topicX}", containerFactory = "topicJmsListenerContainerFactory",
            subscription = "${XXX}")

Method 2:

@JmsListener(destination = "${topicY}", containerFactory = "topicJmsListenerContainerFactory",
        subscription = "${XXX}")

As you can see, the topic names are different, but subscription name is the same.

I get an error in the Springboot app as it's starting up.

Here's the error:

Caused by: javax.jms.JMSRuntimeException: A non-shared durable subscription is already active with name 'XXX'.

I've tried by commenting out 1 of the methods and confirmed it's working, and also tried to connect to a different subscription name and confirmed that that works too. It's just when I have 2 subscriptions with the same name across topics that I get the error above.

Thank you so much!

Edit: 23/01/23 ----- I'm still stuck with this. I haven't found much documentation around this either. Most of the online documentation talk about connecting to different subscriptions with different names, so I haven't come across anything similar to my problem. I don't know at this point whether this is in fact possible or it's a limitation of how JMS works?

Azure Service Bus
Azure Service Bus
An Azure service that provides cloud messaging as a service and hybrid integration.
623 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Mike Urnun 9,811 Reputation points Microsoft Employee
    2023-01-26T01:28:13.12+00:00

    Hello @Kikrigen - Thanks for reaching out and posting on the MS Q&A!

    I'm sourcing from our internal KB on the matter and it looks like the error message, "A non-shared durable subscription is already active with name", is thrown from the qpid-jms client itself, not from Azure Service Bus. We recommend using a shared subscription in this case, but alternatively, you can also try creating a separate connection object (for each subscription you create) to work around this exception.

    If you have any follow-up questions, please let me know in the comments below and I'll dig deeper.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.