Mario Ishac
Mario Ishac

Reputation: 5907

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?

Upvotes: 5

Views: 7267

Answers (3)

Laurentiu Dorin
Laurentiu Dorin

Reputation: 11

In simple terms, a transaction boundary marks the start and end of a transaction. Think of it as drawing a circle around a set of actions to say, "All of these actions should be treated as one big step." Within this boundary, either all of the actions happen together, or if something goes wrong, none of them happen.

Upvotes: 1

Ori Marko
Ori Marko

Reputation: 58832

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.

Upvotes: 1

JB Nizet
JB Nizet

Reputation: 692073

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.

Upvotes: 5

Related Questions