Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'log.connection.close' : false
};
var admin_opts = {
'client.id': 'kafka-nodejs-console-sample-admin',
};
// Add the common options to client and producer
for (var key in driver_options) {
admin_opts[key] = driver_options[key];
}
// Use the AdminClient API to create the topic
// with 1 partition and a retention period of 24 hours.
console.log('Creating the topic ' + topicName + ' with AdminClient');
admin = Kafka.AdminClient.create(admin_opts);
admin.connect();
console.log("AdminClient connected");
admin.createTopic({
topic: topicName,
num_partitions: 1,
replication_factor: 3,
config: { 'retention.ms': (24*60*60*1000).toString() }
},
function(err) {
if(err) {
console.log(err);
} else {
console.log('Topic ' + topicName + ' created');
}