SpringAMQP RabbitMQ如何在没有交换的情况下直接发送到队列 [英] SpringAMQP RabbitMQ how to send directly to Queue without Exchange

查看:57
本文介绍了SpringAMQP RabbitMQ如何在没有交换的情况下直接发送到队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 SpringAMQP 与 Rabbit 模板一起使用.如何将消息直接发送到省略 Exchange 的队列?我该怎么做?

I'm using SpringAMQP with Rabbit template. How to send messages directly to Queues omitting Exchange? How can i do it?

推荐答案

我该怎么做?

你不能;发布者不知道队列;只是交换和路由密钥.

You can't; publishers don't know about queues; just exchanges and routing keys.

但是,所有队列都绑定到默认交换(""),并将队列名称作为其路由键.

However, all queues are bound to the default exchange ("") with the queue name as its routing key.

如果你使用的是Spring AMQP的RabbitTemplate,它默认配置为发布到默认的exchange,所以你可以使用

If you are using Spring AMQP's RabbitTemplate, it is configured to publish to the default exchange by default, so you can use

convertAndSend("myQueue", "foo")`

甚至...

template.setDefaultRoutingKey("myQueue");

然后

template.convertAndSend("foo");

template.send(aMessage);

这篇关于SpringAMQP RabbitMQ如何在没有交换的情况下直接发送到队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆