@Override public void handleReturn(int i, String s, String s2, String s3, AMQP.BasicProperties basicProperties, byte[] bytes) throws IOException { try { Message msg = wire.toMessage(bytes, basicProperties); if (msg instanceof NeedReplyMessage) { Envelope e = envelopes.get(msg.getId()); if (e == null) { retry(msg); logger.warn(String.format("unable to deliver the message; the destination service[%s] is dead; please use rabbitmqctl to check if the queue is existing and if there is any consumers on that queue; message dump:\n%s", msg.getServiceId(), wire.dumpMessage(msg))); } else { MessageReply reply = new MessageReply(); reply.setError(err(SysErrors.UNDELIVERABLE_ERROR, "unable to deliver the message; the destination service[%s] is dead; please use rabbitmqctl to check if the queue is existing and if any consumers on that queue", msg.getServiceId())); e.ack(reply); } } else { retry(msg); logger.warn(String.format("unable to deliver an event; please use rabbitmqctl to check if the queue is existing and if there is any consumers on that queue; message dump:\n%s", wire.dumpMessage(msg))); } } catch (Throwable t) { logger.warn("unhandled throwable", t); } } });