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 am new to Azure SB and topics, so I am not sure if this is something that is even possible to do? Or are multiple subscriptions under different topics not supposed to be named the same?
This is some code I've inherited to debug and find out what the solution might be, so I don't have much details as to why it was done this way. If you need any more information, I am happy to share.
Please help!
I've tried by commenting out 1 of the methods and confirmed it's working.
I want to understand if there is a way to run both methods without errors.
As far as I know every subscription is distinct in a Service Bus Namespace.
Here I was trying to create a new subscription in a different topic while a subscription by the name Subscription
already existed in some other topic the portal gave me the following error
@Component
public class TopicReceiveController {
private static final String TOPIC_NAME1 = "test";
private static final String TOPIC_NAME2 = "newtest";
private static final String SUBSCRIPTION_NAME1 = "Subscription";
private static final String SUBSCRIPTION_NAME2 = "Subscription2";
private final Logger logger = LoggerFactory.getLogger(TopicReceiveController.class);
@JmsListener(destination = TOPIC_NAME1, containerFactory = "topicJmsListenerContainerFactory",
subscription = SUBSCRIPTION_NAME1)
public void receiveMessage(String Name) {
logger.info("Received message: {}", Name);
}
@JmsListener(destination = TOPIC_NAME2, containerFactory = "topicJmsListenerContainerFactory",
subscription = SUBSCRIPTION_NAME2)
public void receiveMessageNewTopic(String Name) {
logger.info("Received message: {}", Name);
}
}
Output:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.