首页新闻找找看学习计划

springboot rabbitmq 怎么实现手动接收消息

0
[待解决问题]

@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状态

卡西莫多_Quasimodo的主页 卡西莫多_Quasimodo | 菜鸟二级 | 园豆:202
提问于:2019-09-02 20:20
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册