当 Kafka 关闭时,我该如何处理 IOException?
2022-09-04 04:42:27
我正在尝试发布消息,而Apache Kafka已关闭。我应该如何处理这样的紧急情况?
KafkaProducer::send() 方法不会引发任何可以处理的异常。生产者吞下它们并记录错误,所以我被这样的消息淹没,一切都会挂起,直到Kafka再次连接。
2014-03-31 09:38:23.752 ERROR o.a.kafka.common.network.Selector - Error in I/O:
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.7.0_51]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) ~[na:1.7.0_51]
at org.apache.kafka.common.network.Selector.poll(Selector.java:205) ~[kafka-clients-0.8.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:212) [kafka-clients-0.8.1.jar:na]
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:150) [kafka-clients-0.8.1.jar:na]
at java.lang.Thread.run(Thread.java:744) [na:1.7.0_51]