本文内容

如何在spring事务提交之后进行一些操作,这些操作必须得在该事务成功提交后才执行,回滚则不执行。

要点

  • 如何在spring事务提交之后操作

  • 如何在spring事务回滚之后操作

实现方案

使用TransactionSynchronizationManager在事务提交之后操作

// send after tx commit but is async
        TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() {
            @Override
            public void afterCommit() {
                System.out.println("send email after transaction commit...");
            }
        }
       );

 

相关文章:

  • 2022-12-23
  • 2022-01-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-18
  • 2021-11-07
  • 2021-08-17
  • 2021-07-18
  • 2021-12-19
相关资源
相似解决方案