title: Kafka & JPA transaction management
body: <p>I am new to Kafka and trying to do transaction management for Kafka and DB transaction. I already read many articles on this topic, but so far I am able to test only 1 scenario successfully.</p>
  <pre><code>@Transactional
  public void updateData(InputData data)
  {
    
    repository.save(data);
    kafkaTemplate.send(data.id,data);
  }
  </code></pre>
  <p>In this case if Kafka transactions fails, DB transaction will be rollback. This works fine.</p>
  <p>But is it possible to do Kafka transaction first &amp; then DB transaction? and if DB transaction fails, then the Kafka transaction will be aborted &amp; message posted on Kafka topic will be in uncommitted state?</p>
  <p>I tested such scenario, but it didn't work. Message posted on topic was not in uncommitted state. Hence want to check possibility of this scenario.</p>