【发布时间】:2018-10-18 11:24:48
【问题描述】:
在文档中 https://docs.spring.io/spring-amqp/reference/htmlsingle/ 我明白了
@RabbitListener(bindings = @QueueBinding(
value = @Queue(value = "myQueue", durable = "true"),
exchange = @Exchange(value = "auto.exch", ignoreDeclarationExceptions = "true"),
key = "orderRoutingKey")
)
public void processOrder(Order order) {
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue,
exchange = @Exchange(value = "auto.exch"),
key = "invoiceRoutingKey")
)
public void processInvoice(Invoice invoice) {
}
这里有 1 个队列和 2 个另外的路由键,每个人都为他的方法 但是我的代码没有从密钥获取消息!
@RabbitListener(bindings = @QueueBinding(
value = @Queue(value = DRIVER_QUEUE, durable = "true"),
exchange = @Exchange(value = "exchange", ignoreDeclarationExceptions = "true", autoDelete = "true"),
key = "order")
)
public String getOrders(byte[] message) throws InterruptedException {
System.out.println("Rout order");
}
@RabbitListener(bindings = @QueueBinding(
value = @Queue(value = DRIVER_QUEUE, durable = "true"),
exchange = @Exchange(value = "exchange", ignoreDeclarationExceptions = "true", autoDelete = "true"),
key = "invoice")
)
public String getOrders(byte[] message) throws InterruptedException {
System.out.println("Rout invoice");
}
他们都从队列中获取消息,但看不到密钥... 站点使用“发票”键发送队列消息,我在控制台“路由顺序”中看到 什么问题??非常感谢!
rabbitmq 3.7.3 春天 4.2.9 org.springframework.amqp 1.7.5
【问题讨论】:
标签: java spring rabbitmq queue