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.31k stars 1.97k forks source link

[BUG] azure-servicebus-jms-spring-boot-starter listener: The messaging entity could not be found #16033

Closed jonasbark closed 3 years ago

jonasbark commented 3 years ago

Describe the bug When I'm trying to create a JmsListener it fails to connect, stating that the messaging entity could not be found

Exception or Stack Trace

WARN 3090 --- [enerContainer-5] o.s.j.l.DefaultMessageListenerContainer  : Setup of JMS message listener invoker failed for destination 'user' - trying to recover. Cause: The messaging entity 'pass-servicebus-d-euwe-10c6dc:Topic:user|qpid-jms:receiver:ID:dc2dd5da-88d3-4529-90ae-d3a3b1b3d2d5:1:1:5:user' could not be found. To know more visit https://aka.ms/sbResourceMgrExceptions.  TrackingId:bbda7699-1769-44a3-aef6-d3f365984e93_B6, SystemTracker:pass-servicebus-d-euwe-10c6dc:Topic:user|qpid-jms:receiver:ID:dc2dd5da-88d3-4529-90ae-d3a3b1b3d2d5:1:1:5:user, Timestamp:2020-10-07T11:37:19 TrackingId:a691965af0ac422caf58471b5d518802_G9, SystemTracker:gateway7, Timestamp:2020-10-07T11:37:19 [condition = amqp:not-found]

To Reproduce

  1. Integrate dependencies:
    api(group = "com.microsoft.azure", name = "azure-servicebus-jms-spring-boot-starter", version = "2.3.5")
    api(group = "com.microsoft.azure", name = "azure-servicebus-jms", version = "0.0.5")
  2. add properties to application.properties: The connection-string is of a Shared access policy from the topic:
    spring.jms.servicebus.connection-string=Endpoint=sb://pass-servicebus-d-euwe-10c6dc.servicebus.windows.net/;SharedAccessKeyName=user-read-write-rule;SharedAccessKey=***=;EntityPath=user
    spring.jms.servicebus.topic-client-id=test
  3. add a Spring class:

    @Component
    class ServiceBusHandler(
     private val jmsTemplate: JmsTemplate
    ) {
    val logger: Logger by LoggerDelegate()
    
    @PostConstruct
    fun test() {
        //jmsTemplate.convertAndSend("user", UserUser())
        println("This actually works")
    }
    
    @JmsListener(
        destination = "user",
        subscription = "user-read-write",
        containerFactory = "jmsListenerContainerFactory"
    )
    fun onUser(user: User) {
    
    }
    }
  4. The error is visible in the logs upon startup

Expected behavior Connection works and messages are received

Setup (please complete the following information):

Additional context Azure Configuration: image image

I double and triple checked the configuration. Sending messages to the topic works fine.

joshfree commented 3 years ago

@jialindai could you please assist in routing this azure-spring issue

han-gao commented 3 years ago

Hi, @jonasbark I follow your configuration, When I'm trying to send a message, JmsListener it fails to connect. When I change the configuration spring.jms.servicebus.topic-client-id to my Service Bus subscription ID, it works.

spring.jms.servicebus.topic-client-id=[Your Subscription ID]

Hope it can help.

jonasbark commented 3 years ago

Hi @han-gao - thanks for replying!

What exactly do you mean with Subscription ID? The Azure Subscription ID? Or the actual subscription name (in my case "user" - see screenshot)?

I tried all different combinations but it still shows the same error message.

han-gao commented 3 years ago

Hi @jonasbark
Not an Azure Subscription ID, When you create a Service Bus in the portal, there is a Subscription ID on the Service Bus overview, such as the picture below, 1603417441(1)

Can you solve your problem?

jonasbark commented 3 years ago

Thank you - I put it in but still no luck for me. Same message I'm afraid.

Now that we're sure the spring.jms.servicebus.topic-client-id part is correct, can we do the same with the other parameters?

spring.jms.servicebus.connection-string: image

JmsListener:

@JmsListener(
        destination = "user",
        subscription = "user-read-write",
        containerFactory = "jmsListenerContainerFactory"
    )

image

Setup of JMS message listener invoker failed for destination 'user' - trying to recover. Cause: The messaging entity 'pass-servicebus-d-euwe-10c6dc:Topic:user|qpid-jms:receiver:ID:5e7c84f5-37dd-4b1a-8f69-ac4a8030f65d:1:1:3:user' could not be found. To know more visit https://aka.ms/sbResourceMgrExceptions. TrackingId:6b10c354-db1b-40c7-9bcb-ff175a435ce8_B16, SystemTracker:pass-servicebus-d-euwe-10c6dc:Topic:user|qpid-jms:receiver:ID:5e7c84f5-37dd-4b1a-8f69-ac4a8030f65d:1:1:3:user, Timestamp:2020-10-23T06:03:42 TrackingId:1f34b6844b894efcbdcb6e2fd864d6a7_G8, SystemTracker:gateway7, Timestamp:2020-10-23T06:03:42 [condition = amqp:not-found]

han-gao commented 3 years ago

@jonasbark Hi, Maybe your JmsListener is not right.

@JmsListener(
        destination = "user",
        subscription = "user-read-write",
        containerFactory = "jmsListenerContainerFactory" //This is the containerFactory for jms queue
    )

You are using jms topic, so your JmsListener should look like the following:

@JmsListener(
        destination = "user",
        subscription = "user-read-write",
        containerFactory = "topicJmsListenerContainerFactory" //This is the containerFactory for jms topic
    )

Can it work?

jonasbark commented 3 years ago

Yes... damn, I didn't catch that. Thanks a lot for your help!

Feel free to close.

I would suggest the Documentation to be updated because https://docs.microsoft.com/de-de/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-service-bus currently states:

spring.jms.servicebus.topic-client-id | Specify the JMS client ID if you're using an Azure Service Bus topic with a durable subscription.

It's not clear that the "Service Bus Subscription ID" is the JMS client ID.

Have a nice day! :)

han-gao commented 3 years ago

@jafreck I'm sorry I didn't read the news on the weekend. I used your configuration to reproduce your problem ,found that your @JmsListener is incorrect. As below: 1603677056(1) I also found that the document is not very clear, the document will be updated immediately.

Have a nice day! :)