@Transactional 是否不足以进行事务管理

is @Transactional not sufficient for transaction management

我一直在 spring 引导应用程序上使用 @Transactional 进行事务管理。但是今天有人告诉我使用narayana进行事务管理。

如果 spring 本身可以为我进行事务管理,为什么我必须使用 narayana。

基本上有两种交易。 Local transactions 特定于单个事务资源,如 JDBC 连接,而 global transactions 可以跨越多个事务资源,如分布式系统中的事务。

如果你需要分布式系统的事务管理,spring事务管理是不够的,narayana 将发挥作用。

来自 Spring 引导文档:

Spring Boot supports distributed JTA transactions across multiple XA resources by using either an Atomikos or Bitronix embedded transaction manager. JTA transactions are also supported when deploying to a suitable Java EE Application Server.

When a JTA environment is detected, Spring’s JtaTransactionManager is used to manage transactions. Auto-configured JMS, DataSource, and JPA beans are upgraded to support XA transactions. You can use standard Spring idioms, such as @Transactional, to participate in a distributed transaction. If you are within a JTA environment and still want to use local transactions, you can set the spring.jta.enabled property to false to disable the JTA auto-configuration.