-
Notifications
You must be signed in to change notification settings - Fork 585
-
Please, What caused the exception?
ERROR 2022年03月23日 02:14:29:begin amq.ctag--sY7m4GwBAyNZ67uXOtWpQ ERROR 2022年03月23日 02:14:29:end com.rabbitmq.client.ShutdownSignalException: clean channel shutdown; protocol method: #method<channel.close>(reply-code=200, reply-text=Closed due to exception from Consumer com.consumerThread1ドル@7fa23ffa (amq.ctag--sY7m4GwBAyNZ67uXOtWpQ) method handleDelivery for channel AMQChannel(amqp://test@10.168.0.221:5675/,1), class-id=0, method-id=0) at com.rabbitmq.client.impl.ChannelN.close(ChannelN.java:554) at com.rabbitmq.client.impl.ChannelN.close(ChannelN.java:509) at com.rabbitmq.client.impl.StrictExceptionHandler.handleChannelKiller(StrictExceptionHandler.java:72) at com.rabbitmq.client.impl.StrictExceptionHandler.handleConsumerException(StrictExceptionHandler.java:61) at com.rabbitmq.client.impl.ConsumerDispatcher5ドル.run(ConsumerDispatcher.java:149) at com.rabbitmq.client.impl.ConsumerWorkService$WorkPoolRunnable.run(ConsumerWorkService.java:99) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745) INFO 2022年03月23日 02:14:39:begin send DI success : 200 INFO 2022年03月23日 02:14:39:end
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 2 comments 3 replies
-
Consider never using GitHub issues for questions, in particular when the repository has Didscussions enabled.
StrictExceptionHandler
, unlike ForgivingExceptionHandler
, closes the channel when any method of your Consumer
interface implementation throws an exception when the library calls it.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thanks for the reminder, I'll keep an eye out for it in the future.
Beta Was this translation helpful? Give feedback.
All reactions
-
I use the consumer handleShutdownSignal
method to catch the exception, then close the channell and connection, and try to re-establish the connection. But if it is StrictExceptionHandler
doesn't seem to work.
Consumer consumer = new DefaultConsumer(channel) {
@Override
public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body) throws IOException {
System.out.println(new String(body));
channel.basicAck(envelope.getDeliveryTag(), false);
}
@Override
public void handleShutdownSignal(String consumerTag, ShutdownSignalException sig) {
// channel.close();
// connection.close();
// try reconnection
}
};
Beta Was this translation helpful? Give feedback.
All reactions
-
handleShutdownSignal
does not handle any exceptions. It is a way to react to a library-initiated shutdown.
Your code must handle any exceptions it may throw. StrictExceptionHandler
will close the channel if any are thrown. It is not the library's responsibility to handle exceptions in your consumer code anyway.
Beta Was this translation helpful? Give feedback.
All reactions
-
Yes, it is react to a library-initiated shutdown. The RabbitMQ source code encapsulates the internal exception handling as ShutdownSignalException
, and consumers obtain exception information through the handleShutdownSignal
method.
Beta Was this translation helpful? Give feedback.