title: How to use transactions in Kafka and how to use abortTransaction?
body: <p>Im new to kafka and I use Kafka Producer Java api.
  Facing this issue with Kafka,
  <code>Kafka: Invalid transition attempted from state COMMITTING_TRANSACTION to state ABORTING_TRANSACTION</code>.</p>
  <p>people have written that <code>producer.abortTransaction()</code> 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?</p>
  <p>This is my code:</p>
  <pre><code>try { 
    producer.send(record, new Callback() { 
      @Override
      public void onCompletion(RecordMetadata recordMetadata, Exception e) { 
        if ( e != null){ 
          logger.info(&quot;Record was not sent due to kafka issue&quot;);
          throw new KafkaException(&quot;Record was not sent due to kafka issue&quot;);
        }
      }
    });
  } catch (KafkaException e){
    producer.abortTransaction(); 
  }
  </code></pre>