Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=

完整错误

CachingConnectionFactory.java:1278 - Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - unknown delivery tag 1, class-id=60, method-id=80)

原因:消费者有ack确认,而spring-boot-starter-amqp默认是自动签收信息的方式,消费结果签收了两次,我们代码里面是写的手动签收,但是系统还有一次自动签收,所以就想到了是不是需要配置一下让rabbitmq手动签署,就不会触发自动签收的功能

channel.basicAck(message.getMessageProperties().getDeliveryTag(), true);

解决方法:去掉自动签收功能

spring:
  rabbitmq:
    host: 127.0.0.1
    port: 5672
    username: guest
    password: guest
    #消费端配置
    listener:
      simple:
        #自动签收auto  手动 manual
        acknowledge-mode: manual

你可能感兴趣的:(学习笔记,rabbitmq,java,spring,boot)