Im new to kafka and I use Kafka Producer Java api.
Facing this issue with Kafka,
Kafka: Invalid transition attempted from state COMMITTING_TRANSACTION to state ABORTING_TRANSACTION.
people have written that producer.abortTransaction() should be called only when there are no transactions in flight....
Any idea how to check whether there are transactions in flight? and how to clear/stop them?
This is my code:
try {
producer.send(record, new Callback() {
@Override
public void onCompletion(RecordMetadata recordMetadata, Exception e) {
if ( e != null){
logger.info("Record was not sent due to kafka issue");
throw new KafkaException("Record was not sent due to kafka issue");
}
}
});
} catch (KafkaException e){
producer.abortTransaction();
}