My Apache Kafka producer (0.9.0.1) intermittently throws a
org.apache.kafka.common.errors.NotLeaderForPartitionException
My code that performs the Kafka send resembles this
final Future<RecordMetadata> futureRecordMetadata = KAFKA_PRODUCER.send(new ProducerRecord<String, String>(kafkaTopic, UUID.randomUUID().toString(), jsonMessage));
try {
futureRecordMetadata.get();
} catch (final InterruptedException interruptedException) {
interruptedException.printStackTrace();
throw new RuntimeException("sendKafkaMessage(): Failed due to InterruptedException(): " + sourceTableName + " " + interruptedException.getMessage());
} catch (final ExecutionException executionException) {
executionException.printStackTrace();
throw new RuntimeException("sendKafkaMessage(): Failed due to ExecutionException(): " + sourceTableName + " " + executionException.getMessage());
}
I catch NotLeaderForPartitionException
within the catch (final ExecutionException executionException) {}
block.
Is it OK to ignore this particular exception?
Has my Kafka message been sent successfully?