什么是交易边界?

What is a transaction boundary?

我已阅读 this article (assumes I already know what a transaction boundary is) and this SO question(无法从该问题中解读事务边界的含义)。换句话说,我发现没有明确的定义或尝试定义事务边界。我明白什么是 100% 的转换,但什么是概念上的事务边界

这是交易开始的地方或者是 committed/rollbacked。

例如用@Transactional注释的方法定义了两个事务边界:当调用该方法时,事务开始,当它returns时,事务是committed/rollbacked。

可以阅读SpringTransaction boundaries参考:

For example, a gateway or service activator method could be annotated with @Transactional, or a TransactionInterceptor could be defined in an XML configuration with a pointcut expression that pointa to specific methods that should be transactional. The bottom line is that you have full control over transaction configuration and boundaries in these scenarios.

Another important factor is the boundaries of Transactions within a Message flow. When a transaction is started, the transaction context is bound to the current thread. So regardless of how many endpoints and channels you have in your Message flow your transaction context will be preserved as long as you are ensuring that the flow continues on the same thread. As soon as you break it by introducing a Pollable Channel or Executor Channel or initiate a new thread manually in some service, the Transactional boundary will be broken as well.