【问题标题】:How to consume a message from a virtual topic with ActiveMQ?如何使用 ActiveMQ 消费来自虚拟主题的消息?
【发布时间】:2020-09-06 19:54:24
【问题描述】:

我正在向名为 VirtualTopic.Orders 的虚拟主题发布消息(通过 spring-jms)。我将消息发布到 ActiveMQ 没有任何问题,并且可以在 VirtualTopic.Orders 队列中看到该消息,但我无法使用它。这是我的 JmsTemplate bean 声明:

<bean id="jmsTemplateBusinessEvents" class="org.springframework.jms.core.JmsTemplate">
    <property name="connectionFactory" ref="jmsConnectionFactory"/>
    <property name="pubSubDomain" value="true"/>
</bean>

由于this explanation,我已将 pubSubDomain 设置为 true。

我还按照here的说明更改了配置文件activemq.xml:

<destinationInterceptors>
    <virtualDestinationInterceptor>
        <virtualDestinations>
            <virtualTopic name="VirtualTopic.>" prefix="Consumer.*.VirtualTopic.>" selectorAware="false"/>
        </virtualDestinations>
     </virtualDestinationInterceptor>
</destinationInterceptors>

这是我的消费者指向 Consumer.A.VirtualTopic.Orders 队列:

<bean class="org.springframework.jms.listener.DefaultMessageListenerContainer" init-method="start"
          lazy-init="false">
    <property name="connectionFactory" ref="jmsConnectionFactory"/>
    <property name="destinationName" value="Consumer.A.VirtualTopic.Orders"/>
    <property name="messageListener" ref="processStatusHandler"/>
</bean>

如果有人可以帮助我,我将不胜感激。

【问题讨论】:

    标签: java spring jms activemq


    【解决方案1】:

    我已经遇到了这个问题。消费者前缀值不正确一定是:

    <destinationInterceptors>
        <virtualDestinationInterceptor>
            <virtualDestinations>
                <virtualTopic name="VirtualTopic.>" prefix="Consumer.*.>" selectorAware="false"/>
            </virtualDestinations>
         </virtualDestinationInterceptor>
    </destinationInterceptors>
    

    【讨论】:

      猜你喜欢
      • 2012-01-03
      • 2018-03-08
      • 2012-05-30
      • 1970-01-01
      • 1970-01-01
      • 2018-04-21
      • 1970-01-01
      • 2012-01-24
      • 2022-01-23
      相关资源
      最近更新 更多