Home >Java >javaTutorial >How to do asynchronous operation after spring transaction commit

How to do asynchronous operation after spring transaction commit

巴扎黑
巴扎黑Original
2017-07-24 15:51:203860browse

Content of this article

How to perform asynchronous operations after the spring transaction is submitted. These asynchronous operations must be executed after the transaction is successfully submitted, and rollback will not be executed.

Key Points

  • How to operate after the spring transaction is submitted

  • How to asynchronousize the operation

Implementation plan

Use TransactionSynchronizationManager to operate after transaction submission

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

The above is the detailed content of How to do asynchronous operation after spring transaction commit. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:My first blog Hello WorldNext article:My first blog Hello World