我什么时候需要定义JMSListenerContainerFactory Bean?

发布于 2025-02-08 06:42:41 字数 770 浏览 2 评论 0原文

我从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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

洋洋洒洒 2025-02-15 06:42:41

如果您使用的是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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文