@RabbitListener(
bindings = @QueueBinding(
value=@Queue(value="w-queue", durable = "true"),
exchange = @Exchange(value = "w-order", durable = "true", type = "direct"),
key = "order.w"
)
)
@RabbitHandler
public void onOrderQueue(@Payload OrderL order, @Headers Map<String, Object> headers, Channel channel){
//消费者操作
System.out.println("---------收到消息,开始消费------");
System.out.println("--------订单ID:" + order.getAccount() + ",name:");
map=order.getMenues();
/* Long deliveryTag = (Long)headers.get(AmqpHeaders.DELIVERY_TAG);
//消息回执 确认收到消息并处理掉了
try {
channel.basicAck(deliveryTag, false);
} catch (IOException e) {
e.printStackTrace();
}*/
}
就是在客户端点击确认后在消息队列里面删除这条消息 否则为unchacked状态