Howto - Spring DynamicDestinationResolver?
我正在使用 Spring、JMS、ActiveMQ。我有一个目标名称为空的 DefaultMessageListenerContainer。我也有一个倾听者。如您所知,侦听器容器可以有多个针对不同目的地的侦听器,如下所示:
<jms:listener-container
container-type="default"
connection-factory="jmsConnectionFactory"
acknowledge="auto" >
<jms:listener destination="TEST.FOO" ref="myMessageListener" method="onMessage" />
<jms:listener destination="foo.bas" ref="myMessageListener" method="onMessage" />
<jms:listener destination="foo.bar" ref="myMessageListener" method="onMessage" />
</jms:listener-container>
在上面的配置中,我提前指定了目的地。但是,我想动态配置目的地。你能告诉我怎么做吗?谢谢!
I'm working with Spring, JMS, ActiveMQ. I have a DefaultMessageListenerContainer with empty destination name. I also have a listener. As you know, a listener container can have many listeners for different destinations as shown below:
<jms:listener-container
container-type="default"
connection-factory="jmsConnectionFactory"
acknowledge="auto" >
<jms:listener destination="TEST.FOO" ref="myMessageListener" method="onMessage" />
<jms:listener destination="foo.bas" ref="myMessageListener" method="onMessage" />
<jms:listener destination="foo.bar" ref="myMessageListener" method="onMessage" />
</jms:listener-container>
In the above configuration, I am specifying the destinations in advance. But, I want to configure destinations dynamically. Could you please tell me how? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您将消息发送到当前未定义的 ActiveMQ 队列,它会为您创建一个具有给定名称的队列。
此网站将引导您了解如何为生成的动态队列动态设置侦听器。该示例使用 RabbitMQ,但您可以将rabbitMQ 连接工厂替换为 ActiveMQ 工厂,并将 RabbitTemplate 替换为 JMSTemplate。其他一切都应该是相同的。该示例在代码中完成了所有操作,但您可以轻松地将逻辑移至 spring 配置中。
If you send a message to an ActiveMQ queue that is not currently defined, it creates a queue for you with the given name.
This site walks you through how to dynamically setup listeners for the dynamic queues that are generated. The example uses RabbitMQ, but you can replace the rabbitMQ connection factory with an ActiveMQ factory and replace the RabbitTemplate with a JMSTemplate. Everything else should be the same. The example does everything in code, but you can easily move the logic into your spring config.