JMS listener - dynamically choose destinations

狂风中的少年 提交于 2019-12-07 17:13:03

问题


I have many destinations (queues) on ActiveMQ deployed on a separate server. I want to dynamically listen to these destinations from my program. Currently I'm listening to these destinations as shown below:

<bean id="jmsConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
    <property name="brokerURL" value="failover://(tcp://192.168.25.26:61616)" />        
</bean>

<bean id="myMessageListener" class="MyMessageListener"></bean>

<jms:listener-container
    container-type="default"
    connection-factory="jmsConnectionFactory"
    acknowledge="auto" >
        <jms:listener destination="TEST.FOO" ref="myMessageListener" />
        <jms:listener destination="foo.bas" ref="myMessageListener" />
        <jms:listener destination="foo.bar" ref="myMessageListener" />        
</jms:listener-container>

I'm able to successfully receive messages from these destinations. However, as you can see I've to add destinations manually in the above configuration. I want to skip this and prefer the listener to dynamically choose the destinations. Is this possible? How? Many thanks in advance for any sort of help/guidance!


回答1:


Have a look at the documentation on Composite Destinations and Destination Wildcards, these two features would allow you to have something close to what you are asking for.



来源:https://stackoverflow.com/questions/9257230/jms-listener-dynamically-choose-destinations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!