我什么时候需要定义JMSListenerContainerFactory Bean?
我从JMS开始,我有几个例子。两者都按预期工作,但是其中一个在其配置类中的一个都具有@bean
jmslistenerconercontainerfactory
的定义。另一个没有任何jmslistenercontainerfactory
bean。
在第一个示例中,如果我评论bean定义,侦听器停止接收消息。 afaik JMSListenerContainerFactory
IS @jmslistener
支持,默认情况下是创建的。在我的理解中,如果需要一些自定义,我可以定义我的,但是在我的示例中,该豆定义没有什么特别的,只是并发设置。 在这里,您有bean的定义:
@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory());
factory.setConcurrency("1-1"); //nro. min-max consumers
return factory;
}
所以,请启发我关于该豆的需求。
I am starting with JMS and I've got a couple of examples. Both work as expected, but one of them in its config class has a @Bean
definition of a JmsListenerContainerFactory
. The other one is not having any JmsListenerContainerFactory
bean.
In the first example if I comment the bean definition the listener stops receiving messages. AFAIK JmsListenerContainerFactory
is @JMSListener
support and is created by default. In my understanding I can define mine if I need some customization, but in my example there is nothing special on that bean definition, just the concurrency setting.
Here you have bean definition:
@Bean
public DefaultJmsListenerContainerFactory jmsListenerContainerFactory() {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory());
factory.setConcurrency("1-1"); //nro. min-max consumers
return factory;
}
So, please enlighten me about the need of that bean.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您使用的是Spring Boot,它将使用application.yml/properties中的属性自动配置容器工厂。
如果您不使用Spring Boot,则必须定义自己的工厂。
If you are using Spring Boot, it automatically configures a container factory using the properties in application.yml/properties.
If you are NOT using Spring Boot, you have to define your own factory.