node-rdkafka
node-rdkafka copied to clipboard
Question: handling consumer stream errors gracefully (stream error, event.error)
Assuming you are using the stream api for consumers a regular error event handler might look like this
this.consumerStream.on('error', error => {
logger.error(
`[${this.name}]: Kafka consumer for topic: ${this.consumerOptions.topicName} caused stream error: ${error.message}`,
error,
);
});
What would be the proper comeback strategy from this? Do you need to check whether the error is fatal or not in (event.error)?. I am wondering how to handle these properly. In case the listener is not there a service would just crash with an uncaughtException. Any advise is much appreciated.