I wrote producer Kafka in NodeJS and Kafka Consumer in Java Maven. My theme is a โtestโ that was created by the following command:
bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test
Manufacturer at NodeJS:
var kafka = require('kafka-node'); var Producer = kafka.Producer; var Client = kafka.Client; var client = new Client('localhost:2181'); var producer = new Producer(client); producer.on('ready', function () { producer.send([ { topic: 'test', partition: 0, messages: ["This is the zero message I am sending from Kafka to Spark"], attributes: 0}, { topic: 'test', partition: 1, messages: ["This is the first message I am sending from Kafka to Spark"], attributes: 0}, { topic: 'test', partition: 2, messages: ["This is the second message I am sending from Kafka to Spark"], attributes: 0} ], function (err, result) { console.log(err || result); process.exit(); }); });
When I send two messages from the NodeJS manufacturer, it is successfully consumed by the Java consumer. But when I send three or more messages from the NodeJS manufacturer, this leads to the following error:
{[BrokerNotAvailableError: Could not find a leader] message: "Could not find a leader"}
I want to ask how can I install LEADER on any message in the "test" topic. Or what should be the solution to the problem.
source share