Log4j2 kafka 附加程序故障转移无法正常工作,并且出现此错误“代理可能不可用”

发布于 2025-01-14 09:10:07 字数 1734 浏览 0 评论 0原文

我有这个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文