I am using NodeJS to consume message from Kafka, after received the message , I will bring it to create an index in Elasticsearch. This is my piece of code :
kafkaConsumer.on('message', function (message) {
elasticClient.index({
index: 'test',
type: 'sample',
body: message
}, function (error, response) {
if (error) {
// Stop consuming message here
console.log(error);
}
console.log(response);
});
});
I want to make sure that the index must be created successfully before continue consuming next message, because I don't want any message to be lost.