@GlobalTransactional(rollbackFor = Exception.class)
时间: 2023-11-11 13:33:52 浏览: 148
This annotation is used in distributed transactions to mark a method that participates in a global transaction. It is used in combination with Spring Cloud Alibaba's Seata framework to manage distributed transactions across multiple microservices.
The annotation is responsible for starting a global transaction and enlisting all the transactional resources involved in the transaction. If any exception occurs during the execution of the annotated method or any of the participating resources, Seata will automatically take care of rolling back the entire transaction.
The rollbackFor parameter in the annotation specifies the exception types that should trigger a rollback of the transaction. By default, the annotation will rollback for any unchecked exceptions (i.e. RuntimeExceptions) and any checked exceptions that are annotated with @Transactional or @TransactionAttribute.
Overall, @GlobalTransactional is a powerful annotation that simplifies the management of distributed transactions in a microservices architecture, ensuring data consistency and preventing data corruption.
阅读全文