Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
445 views
in Technique[技术] by (71.8m points)

java - Whether topicJmsListenerContainerFactory supports asynchronous Processing - Azure Spring JMS?

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 ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...