Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

com.rabbitmq.client.impl.StrictExceptionHandler.handleConsumerException(StrictExceptionHandler.java:61) #867

zfy68 started this conversation in General
Discussion options

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

You must be logged in to vote

Replies: 2 comments 3 replies

Comment options

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.

You must be logged in to vote
1 reply
Comment options

Thanks for the reminder, I'll keep an eye out for it in the future.

Comment options

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
 }
 };
You must be logged in to vote
2 replies
Comment options

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.

Comment options

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Converted from issue

This discussion was converted from issue #866 on October 14, 2022 15:20.

AltStyle によって変換されたページ (->オリジナル) /