I am dynamically creating a series of topics using KafkaJS, and found that in order to do so without creating election problems I should use the createTopics
admin feature.
The issue is that if createTopics
is called on a topic that already exist, it does not just return false
(as is documented), but it also emits an error stating "Topic with this name already exists".
{"level":"ERROR","timestamp":"2020-08-24T18:19:48.465Z","logger":"kafkajs","message":"[Connection] Response CreateTopics(key: 19, version: 2)","broker":"localhost:9092","clientId":"tv-kitchen","error":"Topic with this name already exists","correlationId":2,"size":86}
I realize this error comes straight out of the Kafka protocol but I'm concerned because, well, errors are errors.
Is it safe for me to run createTopics
even if it might risk creating a topic that already exists, or do I need to do some type of error handling as well?
If it is safe, is it possible to silence that error, since it is ultimately noise?