title: Does database @Transactional work with @KafkaListener?
body: <p>I'm looking at <a href="https://stackoverflow.com/questions/61142419/how-to-use-transactional-with-kafkalistener">How to use @Transactional with @KafkaListener?</a> but it sounds like it does not work and I'm having issues where Spring JPA is giving a the following error <a href="https://stackoverflow.com/questions/2743130/hibernate-batch-update-returned-unexpected-row-count-from-update-0-actual-row">Batch update returned unexpected row count</a>.</p>
  <p>I tried</p>
  <pre><code>    @KafkaListener(topics = ... )
      @Transactional(
          propagation = Propagation.REQUIRES_NEW,
          isolation = Isolation.READ_COMMITTED
      )
  </code></pre>
  <p>It didn't seem to work.</p>
  <p>I haven't tried yet but I am thinking I would have to do</p>
  <pre><code>@Autowired PlatformTransactionManager transactionManager;
  
  @KafkaListener(topics = ... )
  public void foo(Blah blah) {
  
    var def = new DefaultTransactionDefinition();
    def.setPropagationBehavior(
      TransactionDefinition.PROPAGATION_REQUIRES_NEW);
    def.setIsolationLevel(
      TransactionDefinition.ISOLATION_READ_COMMITTED);
    new TransactionTemplate(transactionManager, def)
      .executeWithoutResult(tx-&gt; {
        ...
      });
  
  }
  </code></pre>