如何使用ActiveMQ消耗一个虚拟主题的消息?

问题描述 投票:0回答:1

我正在发布一条消息到一个虚拟主题,名为 虛擬主題.訂單 (通过spring-jms)。我把消息发布到ActiveMQ上,没有任何问题,我可以看到消息在 虛擬主題.訂單 队列,但我无法消耗它。这是我的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>

这里是我的消费者指向 消费者.A.虚拟主题.订单 队列。

<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个回答
0
投票

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

<destinationInterceptors>
    <virtualDestinationInterceptor>
        <virtualDestinations>
            <virtualTopic name="VirtualTopic.>" prefix="Consumer.*.>" selectorAware="false"/>
        </virtualDestinations>
     </virtualDestinationInterceptor>
</destinationInterceptors>
© www.soinside.com 2019 - 2024. All rights reserved.