【发布时间】:2021-10-08 11:53:33
【问题描述】:
我在使用 Spring boot 2.0.3.RELEASE 时遇到了 ActiveMQ Artemis 2.17.0 的监听器问题。 我使用 Spring Boot Artemis 依赖项将消息发送到多个 队列 通过:
jmsTemplate.convertAndSend(destination, message)
我将消息发送到 3 个不同的队列:
- queue.test1.event
- queue.test2.event
- queue.test2.event
在侦听器端,我使用通配符读取所有队列,例如:
@JmsListener(destination = "queue.#")
public void receiveMessage(String event) {
//....
}
但我什么也得不到。
Web 控制台显示我有 4 个队列(上面提到的 3 个,另一个为 queue.#),WildcardRoutingEnabled 也设置为 true。
This official Artemis documentation 解释了 Artemis 通配符模式,我正在关注它。不知道为什么它不起作用。
PS:我之前在 ActiveMQ 中使用过 ActiveMQ 通配符模式,它与 Spring boot ActiveMQ 依赖项完美配合(使用此侦听器:@JmsListener(destination = "queue.>"))
我也评论了Wildcard routing not working in ActiveMQ Artemis,但由于原来的帖子太旧了,我决定在这里重新发布新的问题。让我知道我是否必须还原它。
【问题讨论】:
-
添加您创建消费者的要点是什么?是在您发送消息之前还是之后?
-
感谢您的回复,让我试试那个,但对于 ActiveMQ 没关系。之后我创建了我的监听器,它能够使用通配符监听所有队列。
-
嗨@JustinBertram,你是对的。非常感谢。但这仍然很奇怪,因为我无法保证听者或制作者的顺序。
-
您可以在
broker.xml中预先创建资源,以避免消费者和生产者之间的竞争条件。 -
我不能,因为我在一个动态的多租户环境中工作,每个队列都代表一个租户,它们是动态的。非常感谢您的帮助
标签: spring-boot jms activemq-artemis