protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - unknown delivery tag 2, class-id=60, method-id=80)
Caused by: com.rabbitmq.client.ShutdownSignalException: channel error; reason: {#method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - unknown delivery tag 18 - 后面的忘了
INFO | jvm 1 | 2017/02/23 14:28:43 | at java.lang.Thread.run(Thread.java:745)
INFO | jvm 1 | 2017/02/23 14:28:43 | Exception in thread "LDService-Worker-3" com.rabbitmq.client.AlreadyClosedException: channel is already closed due to channel error; protocol method: #method<channel.close>(reply-code=406, reply-text=PRECONDITION_FAILED - unknown delivery tag 2, class-id=60, method-id=80)
INFO | jvm 1 | 2017/02/23 14:28:43 | at com.rabbitmq.client.impl.AMQChannel.ensureIsOpen(AMQChannel.java:195)
INFO | jvm 1 | 2017/02/23 14:28:43 | at com.rabbitmq.client.impl.AMQChannel.transmit(AMQChannel.java:309)
INFO | jvm 1 | 2017/02/23 14:28:43 | at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:657)
INFO | jvm 1 | 2017/02/23 14:28:43 | at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:640)
INFO | jvm 1 | 2017/02/23 14:28:43 | at com.rabbitmq.client.impl.ChannelN.basicPublish(ChannelN.java:631)
INFO | jvm 1 | 2017/02/23 14:28:43 | at com.rabbitmq.client.impl.recovery.AutorecoveringChannel.basicPublish(AutorecoveringChannel.java:168)
INFO | jvm 1 | 2017/02/23 14:28:43 | at com.ld.net.remoting.rmq.XXX$DealRequest.processRequest(XXX.java:567)
INFO | jvm 1 | 2017/02/23 14:28:43 | at com.ld.net.remoting.rmq.XXX$3$1.run(XXX.java:208)
INFO | jvm 1 | 2017/02/23 14:28:43 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
INFO | jvm 1 | 2017/02/23 14:28:43 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
原因:经多次重复测试,应该是客户端double ack的原因。
如果启用了批量ack的,将channel.basicAck(envelope.getDeliveryTag(), true); 改为channel.basicAck(envelope.getDeliveryTag(), false);
否则,检查下是否在basicConsume的时候设置了autoAck,同时业务代码里面又调用了channel.basicAck。
除此之外,还可能有下列错误:
com.rabbitmq.client.ShutdownSignalException: clean channel shutdown; protocol method: #method<channel.close>(reply-code=200, reply-text=OK, class-id=0, method-id=0)
INFO | jvm 1 | 2017/02/24 10:28:59 | 17-02-24 10:28:58 ERROR CF-TP-37 XXX$3.handleDelivery(XXX.java:226): 处理消息的时候发生异常,会导致channel关闭,需要重启
INFO | jvm 1 | 2017/02/24 10:28:59 | java.util.concurrent.RejectedExecutionException: Task XXXX.$3$1@722bfd74 rejected from java.util.concurrent.ThreadPoolExecutor@33b8fcd1[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 476]
INFO | jvm 1 | 2017/02/24 10:28:59 | at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047)
INFO | jvm 1 | 2017/02/24 10:28:59 | at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823)
INFO | jvm 1 | 2017/02/24 10:28:59 | at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1369)
INFO | jvm 1 | 2017/02/24 10:28:59 | at XXX.$3.handleDelivery(LDMultiServiceBeanConfigurer.java:205)
INFO | jvm 1 | 2017/02/24 10:28:59 | at com.rabbitmq.client.impl.ConsumerDispatcher$5.run(ConsumerDispatcher.java:144)
INFO | jvm 1 | 2017/02/24 10:28:59 | at com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:99)
INFO | jvm 1 | 2017/02/24 10:28:59 | at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
INFO | jvm 1 | 2017/02/24 10:28:59 | at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
INFO | jvm 1 | 2017/02/24 10:28:59 | at java.lang.Thread.run(Thread.java:745)
这不一定是MQ自身的问题,有可能是客户端有其他的非MQ相关的异常没有被捕获导致线程抛出异常,进而导致相关MQ消费者线程也异常,详细看日志。