Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what does suspending a transaction means?

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?

update

what happens to the resource held by suspended transaction?

like image 471
eatSleepCode Avatar asked Nov 16 '15 06:11

eatSleepCode


People also ask

What does suspended sale mean?

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.

What is suspend amount?

Suspension Amounts means all monies held in suspense and for the account of Third Parties as of the Closing Date.


1 Answers

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.enter image description here

PROPAGATION_REQUIRES_NEW uses a completely independent transaction for each affected transaction scope. The underlying physical transactions are different and hence can commit or roll back independently. Here the outer transaction is not affected by an inner 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!

like image 131
SyntaX Avatar answered Nov 08 '22 12:11

SyntaX