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

Channel shutdown: channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=
强烈推介IDEA2021.1.3破解激活,IntelliJ IDEA 注册码,2021.1.3IDEA 激活码  

大家好,我是架构君,一个会写代码吟诗的架构师。今天说一说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

 

本文来源huayang183,由架构君转载发布,观点不代表Java架构师必看的立场,转载请标明来源出处:https://javajgs.com/archives/18060

发表评论