title: Kafka producer throws an error Invalid transition attempted from state IN_TRANSACTION to state IN_TRANSACTION
body: <p>My kafka producer is throwing an error &quot;Invalid transition attempted from state IN_TRANSACTION to state IN_TRANSACTION&quot;. Here is what I am trying to achieve -</p>
  <pre><code>KafkaProducer producer = new KafkaProducer&lt;&gt;(props);
  producer.initTransactions();
  //transaction 1
  producer.beginTransaction();
  //send some messages
  producer.commitTransaction();
  
  //transaction 2
  producer.beginTransaction(); //here it throws an exception &quot;Invalid transition attempted from state IN_TRANSACTION to state IN_TRANSACTION&quot;.
  //send some messages
  producer.commitTransaction();
  
  producer.close();
  </code></pre>
  <p>If I call <code>producer.initTransactions();</code> again before starting transaction 2, it throws an exception &quot;Invalid transition attempted from state READY to state INITIALIZING&quot;.</p>
  <p>What am I doing wrong?</p>