【问题标题】:SpringAMQP RabbitMQ how to send directly to Queue without ExchangeSpringAMQP RabbitMQ如何在没有Exchange的情况下直接发送到队列
【发布时间】:2017-09-10 12:14:57
【问题描述】:

我正在使用带有 Rabbit 模板的 SpringAMQP。如何将消息直接发送到省略 Exchange 的队列?我该怎么做?

【问题讨论】:

    标签: spring rabbitmq send spring-amqp spring-rabbit


    【解决方案1】:

    我该怎么做?

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

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

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

    convertAndSend("myQueue", "foo")`
    

    甚至……

    template.setDefaultRoutingKey("myQueue");
    

    然后

    template.convertAndSend("foo");
    

    template.send(aMessage);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-06-09
      • 2016-05-21
      • 2020-02-03
      相关资源
      最近更新 更多