-
Notifications
You must be signed in to change notification settings - Fork 625
Open
Description
Bug Report
The following implies that calling producer.createTopics(['x']. false) blocks the execution until the Kafka's topic is created.
When async is set to false, this method does not return until all topics are created
Which does not seem to be the case according to https://github.com/SOHU-Co/kafka-node/blob/master/lib/client.js#L369
The function uses retry which uses setTimout. It simply calls cb(null), returns and keeps retrying asynchronously.
createTopics(topics, async, cb)
This method is used to create topics on the Kafka server. It only works when auto.create.topics.enable, on the Kafka server, is set to true. Our client simply sends a metadata request to the server which will auto create topics. When async is set to false, this method does not return until all topics are created, otherwise it returns immediately.
topics: Array, array of topics
async: Boolean, async or sync
cb: Function, the callback
Example:
var kafka = require('kafka-node'),
Producer = kafka.Producer,
client = new kafka.Client(),
producer = new Producer(client);
// Create topics sync
producer.createTopics(['t','t1'], false, function (err, data) {
console.log(data);
});
// Create topics async
producer.createTopics(['t'], true, function (err, data) {});
producer.createTopics(['t'], function (err, data) {});// Simply omit 2nd arg
Environment
- Node version:
- Kafka-node version:
- Kafka version:
For specific cases also provide
- Number of Brokers:
- Number partitions for topic:
Include Sample Code to reproduce behavior
// include code hereInclude output with Debug turned on
Thanks for your contribution!
Wenzil
Metadata
Metadata
Assignees
Labels
No labels