1
votes

I'm trying to read the messages asynchronously from azure service bus topic. I have created the JMS Listener based on MS documentation

  @JmsListener(destination = TOPIC_NAME, containerFactory = "topicJmsListenerContainerFactory",
            subscription = SUBSCRIPTION_NAME)
    public void receiveMessage(User user) {
        logger.info("Received message: {}", user.getName());
    }

I need to ensure whether topicJmsListenerContainerFactory container factory supports asynchronous processing ?

Spring documentation says enter image description here

I tried Implementing the DefaultJmsListenerContainerFactory like below, but by using this I can't able to fetch any messages from service bus top. It throwing an exception The messaging entity could not be found. I'm able to fetch messages by using topicJmsListenerContainerFactory container factory

@Bean
@ConditionalOnMissingBean(name = "jmsListenerContainerFactory")
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory(DefaultJmsListenerContainerFactoryConfigurer Configure, ConnectionFactory connectionFactory) {
    DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
    Configure.configure(factory, connectionFactory);
    return factory;
}

Reference :

https://docs.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-boot-starter-java-app-with-azure-service-bus

How to create DefaultMessageListenerContainer in Spring-Boot?

https://docs.microsoft.com/en-us/java/api/com.azure.spring.autoconfigure.jms.servicebusjmsautoconfiguration.topicjmslistenercontainerfactory?view=azure-java-preview

https://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/jms/annotation/JmsListener.html

Any one please advise on this ?

1

1 Answers

1
votes

Yes it does. A quick look at https://github.com/Azure/azure-sdk-for-java/blob/e81850c3fcebe0bbfe65ed3e8a1c7c0c607798cf/sdk/spring/azure-spring-boot/src/main/java/com/azure/spring/autoconfigure/jms/ServiceBusJMSAutoConfiguration.java#L71

Provides that topicJmsListenerContainerFactory is also an instance of DefaultJmsListenerContainerFactory class, as we know DefaultJmsListenerContainerFactory provides all the goodness of Spring JMS so it should be working fine.