Java连接RabbitMQ实例(4)

@RabbitListener(bindings = @QueueBinding(value = @Queue(value = RabbitMQConfig.DIRECT_QUEUE, durable = "true"), exchange = @Exchange(value = RabbitMQConfig.DIRECT_EXCHANGE, durable = "true", type = ExchangeTypes.DIRECT), key = RabbitMQConfig.DIRECT_ROUTINGKEY))
 @RabbitHandler
 @Override
 public void receiveOrderTopicMessage(@Payload Order order, Channel channel, @Headers Map<String, Object> headers) throws IOException {
 if (logger.isDebugEnabled()) {
 logger.debug("消费端Payload:" + order);
 }
 Long deliveryTag = (Long) headers.get(AmqpHeaders.DELIVERY_TAG);
 //手工ack
 channel.basicAck(deliveryTag, false);
 }
}

Linux公社的RSS地址https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/1859b61d160e88471f5f347723086680.html