繁体   English   中英

如何使用 ActiveMQ 消费来自虚拟主题的消息?

[英]How to consume a message from a virtual topic with ActiveMQ?

我正在向名为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>

由于这个解释,我已将 pubSubDomain 设置为 true。

我还更改了配置文件 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>

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM