Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is a transaction boundary?

I've read this article (assumes I already know what a transaction boundary is) and this SO question (can't decipher meaning of transaction boundary from that question). In other words, there are no clear definitions or attempts at definitions for transaction boundary that I have found. I understand what a transition is 100%, but what is a transaction boundary conceptually?

like image 464
Mario Ishac Avatar asked Nov 15 '18 07:11

Mario Ishac


2 Answers

It's where the transaction starts or is committed/rollbacked.

A method annotated with @Transactional for example defines two transaction boundaries: when the method is called, a transaction starts, and when it returns, the transaction is committed/rollbacked.

like image 122
JB Nizet Avatar answered Oct 20 '22 11:10

JB Nizet


You can read Spring Transaction boundaries reference:

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.

like image 30
user7294900 Avatar answered Oct 20 '22 10:10

user7294900