RabbitTemplate通过路由名称通配符将消息发送到主题

时间:2019-11-11 11:12:12

标签: spring-rabbitmq

我使用RabbitTemplate.convertAndSend通过通配符将消息发送到主题中的所有路由。

rabbitTemplate.convertAndSend(
        "/topic/javainuse.*",
        "{\"sender\":\"asfasf\",\"content\":\"asf\",\"type\":\"CHAT\"}");

但是它不起作用,我的路线是javainuse.49a56fc8-9cf7-41dd-a87d-4cb4016ddc91未收到消息。这是我的rabbitMQ图像:

enter image description here

请帮助我修复它。谢谢。

1 个答案:

答案 0 :(得分:1)

这种方式行不通;生产者不能使用通配符。

您可以使用密钥foo.*绑定队列,然后使用密钥foo.barfoo.baz进行发送。