【问题标题】:Is it possible to configure a jmsTemplate Topic publisher and also a Queue message producer in the same springboot application [closed]是否可以在同一个springboot应用程序中配置jmsTemplate主题发布者和队列消息生产者[关闭]
【发布时间】:2019-09-05 19:22:49
【问题描述】:

我的应用程序最初使用的是队列,所以我还需要为同一个应用程序实现一个主题。我在设置配置时遇到了困难。请大家帮忙

【问题讨论】:

    标签: spring-boot spring-jms jms-topic jmstemplate jms-queue


    【解决方案1】:

    只需定义两个 JmsTemplate bean

        @Bean
        public JmsTemplate jmsTemplate(ConnectionFactory connectionFactory) {
            JmsTemplate template = new JmsTemplate(connectionFactory);
            template.setPubSubDomain(false);
            return template;
        }
    
        @Bean
        public JmsTemplate jmsTemplatePubSub(ConnectionFactory connectionFactory) {
            JmsTemplate template = new JmsTemplate(connectionFactory);
            template.setPubSubDomain(true);
            return template;
        }
    

    这将阻止 Boot 声明自己的模板

    【讨论】:

    • 非常感谢。有效。确保我给了 Bean 的名字。
    猜你喜欢
    • 1970-01-01
    • 2019-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-13
    • 2023-03-06
    • 2015-08-03
    • 2011-01-10
    相关资源
    最近更新 更多