我正在使用 Spring AMQP 和 Rabbitmq 模板。如何直接将消息发送到队列而不使用Exchange?我该怎么做?
我该怎么做?
你不能;发布者不知道队列;只是交换和路由密钥。
但是,所有队列都绑定到默认交换器(""
)以队列名称作为其路由键。
如果您使用 Spring AMQPRabbitTemplate
,它默认配置为发布到默认交易所,因此您可以使用
convertAndSend("myQueue", "foo")`
甚至...
template.setDefaultRoutingKey("myQueue");
then
template.convertAndSend("foo");
or
template.send(aMessage);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)