Log4j2 kafka 附加程序故障转移无法正常工作,并且出现此错误“代理可能不可用”
我有这个 log4j2.xml 文件,我不明白为什么当 Kafka 附加器失败时故障转移附加器不起作用。 我的 Kafka 附加程序是:
<Kafka name="kafka" topic="myTopic" ignoreExceptions="false" >
<JsonLayout />
<Property name="bootstrap.servers">127.0.0.1:9092</Property>
</Kafka>
我的故障转移附加程序是:
<FailOver name="fail-over" primary="kafka" ignoreExceptions="false">
<Failovers>
<AppenderRef ref="randomFile" />
</Failovers>
</FailOver>
我的根级别是:
<Root level="info" includeLocation="false">
<AppenderRef ref="fail-over" />
</Root>
但由于某种原因,我不断收到连接拒绝错误,确切地说是:
16:32:05.669 [kafka-producer-network-thread | producer-1] DEBUG org.apache.kafka.common.network.Selector - [Producer clientId=producer-1] Connection with /127.0.0.1 disconnected
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:50)
at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:224)
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:526)
at org.apache.kafka.common.network.Selector.poll(Selector.java:481)
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:561)
at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:327)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:242)
at java.lang.Thread.run(Thread.java:748)
I have this log4j2.xml file I don't understand why Failover appender is not working when Kafka appender is failing.
My Kafka appender is:
<Kafka name="kafka" topic="myTopic" ignoreExceptions="false" >
<JsonLayout />
<Property name="bootstrap.servers">127.0.0.1:9092</Property>
</Kafka>
My Failover appender is:
<FailOver name="fail-over" primary="kafka" ignoreExceptions="false">
<Failovers>
<AppenderRef ref="randomFile" />
</Failovers>
</FailOver>
My root level is:
<Root level="info" includeLocation="false">
<AppenderRef ref="fail-over" />
</Root>
But for some reason I keep getting connection refusal error which exactly is:
16:32:05.669 [kafka-producer-network-thread | producer-1] DEBUG org.apache.kafka.common.network.Selector - [Producer clientId=producer-1] Connection with /127.0.0.1 disconnected
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at org.apache.kafka.common.network.PlaintextTransportLayer.finishConnect(PlaintextTransportLayer.java:50)
at org.apache.kafka.common.network.KafkaChannel.finishConnect(KafkaChannel.java:224)
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:526)
at org.apache.kafka.common.network.Selector.poll(Selector.java:481)
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:561)
at org.apache.kafka.clients.producer.internals.Sender.runOnce(Sender.java:327)
at org.apache.kafka.clients.producer.internals.Sender.run(Sender.java:242)
at java.lang.Thread.run(Thread.java:748)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论