0
绑定我试图发送消息如下:消息不发送,如果我不指定队列,TopicExchange,在SpringBootApplication
rabbitTemplate.convertAndSend("my.exchange", "my.queue", "Test Message");
并试图如下接收消息:
@RabbitListener(bindings = @QueueBinding(value = @Queue(value = "my.queue", durable = "true"), exchange = @Exchange(value = "my.exchange", durable = "true", type = ExchangeTypes.TOPIC)))
public void receiveAuditMessage(String message) {
log.info("Received <" + message + ">");
}
这不起作用。
但是,如果我指定@SpringBootApplication中的Queue,TopicExchange,Binding,那么它的工作正常。
@Bean
Queue queue() {
return new Queue("my.queue");
}
@Bean
TopicExchange exchange() {
return new TopicExchange("my.exchange");
}
@Bean
Binding binding(Queue queue, TopicExchange exchange) {
return BindingBuilder.bind(queue).to(exchange).with("my.queue");
}
是否必须指定队列,TopicExchange,在SpringBootApplication绑定? 如果是,那么如何在SpringBootApplication中指定多个Queue,TopicExchange,Binding?
请帮我这里。谢谢。
非常感谢。它在添加密钥后工作。 – Krish