5.消息确认

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_16855077/article/details/81316423

消息由生产者发送出去之后,生产者必须确定我收到这条消息了,不然,生产者会任务这条消息,一直没有收到。

1.helloworld模式

 //参数2 自动确认
  channel.basicConsume(QUEUE, true, consumer);

2.work模式

    //注册消费者    参数2 手动确认   代表我们收到消息后,需要手动告诉服务器,我收到消息了
        channel.basicConsume(QUEUE, false, consumer);

猜你喜欢

转载自blog.csdn.net/qq_16855077/article/details/81316423