我已经在我们的Spring Boot微服务上工作了几个月,最近又让他们使用Kafka进行排队。
为此,我一直在运行单个本地Zookeeper和Broker。我试图保留判断力,但发现卡夫卡非常不稳定,经常出车祸且行为无法预测。
最新一期出现在一夜之间。我没有更改Zookeeper或代理的配置,也没有更改它们的启动方式,但是现在Kafka附带的控制台使用者抛出了InvalidReceiveException,这是以前没有做过的。
当该主题存在或不存在并且我是否已清除数据时,就会发生这种情况。
由于我没有进行任何更改,甚至没有尝试连接我的服务,因此我对可能出了什么问题感到茫然。
Zookeeper配置:
dataDir=C:/tools/kafka/data/zookeeper
clientPort=2181
maxClientCnxns=0
Zookeeper启动命令:
bin/windows/zookeeper-server-start.bat config/zookeeper.properties
经纪人配置:
broker.id=0
num.network.threads=3
num.io.threads=8
socket.send.buffer.bytes=102400
socket.receive.buffer.bytes=102400
socket.request.max.bytes=104857600
log.dirs=C:/tools/kafka/data/kafka-logs
num.partitions=1
num.recovery.threads.per.data.dir=1
offsets.topic.replication.factor=1
transaction.state.log.replication.factor=1
transaction.state.log.min.isr=1
log.retention.hours=168
log.segment.bytes=1073741824
log.retention.check.interval.ms=300000
zookeeper.connect=localhost:2181
zookeeper.connection.timeout.ms=6000
group.initial.rebalance.delay.ms=0
经纪人启动命令:
bin/windows/kafka-server-start.bat config/server.properties
主题创建:
bin/windows/kafka-topics.bat --zookeeper localhost:2181 --create --topic outbound.dlr.dev1 --partitions 1 --replication-factor 1
控制台使用者命令:
bin/windows/kafka-console-consumer.bat --bootstrap-server localhost:9042 --topic outbound.dlr.dev1 --group foo
堆栈跟踪:
[2018-10-12 12:18:43,962] WARN [Consumer clientId=consumer-1, groupId=foo] Unexpected error from localhost/127.0.0.1; closing connection (org.apache.kafka.common.network.Selector)
org.apache.kafka.common.network.InvalidReceiveException: Invalid receive (size = -2147483648)
at org.apache.kafka.common.network.NetworkReceive.readFrom(NetworkReceive.java:102)
at org.apache.kafka.common.network.KafkaChannel.receive(KafkaChannel.java:335)
at org.apache.kafka.common.network.KafkaChannel.read(KafkaChannel.java:296)
at org.apache.kafka.common.network.Selector.attemptRead(Selector.java:560)
at org.apache.kafka.common.network.Selector.pollSelectionKeys(Selector.java:496)
at org.apache.kafka.common.network.Selector.poll(Selector.java:425)
at org.apache.kafka.clients.NetworkClient.poll(NetworkClient.java:510)
at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.poll(ConsumerNetworkClient.java:271)
at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.poll(ConsumerNetworkClient.java:242)
at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.poll(ConsumerNetworkClient.java:233)
at org.apache.kafka.clients.consumer.internals.ConsumerNetworkClient.awaitMetadataUpdate(ConsumerNetworkClient.java:161)
at org.apache.kafka.clients.consumer.internals.AbstractCoordinator.ensureCoordinatorReady(AbstractCoordinator.java:243)
at org.apache.kafka.clients.consumer.internals.ConsumerCoordinator.poll(ConsumerCoordinator.java:314)
at org.apache.kafka.clients.consumer.KafkaConsumer.updateAssignmentMetadataIfNeeded(KafkaConsumer.java:1218)
at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1181)
at org.apache.kafka.clients.consumer.KafkaConsumer.poll(KafkaConsumer.java:1115)
at kafka.tools.ConsoleConsumer$ConsumerWrapper.<init>(ConsoleConsumer.scala:387)
at kafka.tools.ConsoleConsumer$.run(ConsoleConsumer.scala:71)
at kafka.tools.ConsoleConsumer$.main(ConsoleConsumer.scala:53)
at kafka.tools.ConsoleConsumer.main(ConsoleConsumer.scala)