If we are using Propagation Requires_new then it suspends existing transaction and creates a new transaction. So what does it mean to suspends a transaction? what happens to the suspended transaction? what exactly happens behind the scene?
what happens to the resource held by suspended transaction?
Suspended sale means any first marketing of farm tobacco at a ware house sale for which a memorandum of sale is not issued by the end of the sale day on which such marketing occurred.
Suspension Amounts means all monies held in suspense and for the account of Third Parties as of the Closing Date.
First of all the question here is a duplication of the thread: How does transaction suspension work in Spring?. However, I will try to answer this in a different way.
To understand the working of Spring @Transaction API, we must look inside the transaction propagation mechanism.
Spring managed transaction has physical and logical transactions depending upon the configuration.
PROPAGATION_REQUIRES_NEWuses a completely independent transaction for each affected transaction scope. The underlying physical transactions are different and hence can commit or roll backindependently. Here theouter transactionis not affected by aninner transaction’s rollback status.
When a transaction is suspended, it waits until it can pick up where it left off. This means, the changes that happened while the transaction is suspended are NOT part of the same atomic unit. In other words, the things that happened while the transaction is suspended won’t be rolled back if the suspended transaction (after it comes back to life) fails to commit.
Spring transaction does not expose any API for developers to control this directly, other than the transaction configurations. However if you are using JTA to manage transaction then you can call the suspend and resume methods as below:
Transaction tobj = TransactionManager.suspend();
..
TransactionManager.resume(tobj);
I hope this helps you!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With