ParkCheolu
ParkCheolu

Reputation: 1275

Does Spring Transaction have its own timer for timeout?

I got from my Internet research, that Spring Transaction has its own timer checking if transactions exceeded its timeout values set. I have tested several times for this with AspectJ, but I have never found such timer processes during a transaction execution. Is it really true that Spring Transaction timeout works with its own timer?

What I found out is that it seems like Spring Transaction stores a start time(or end time) of a transaction then checks if current time exceeds the end time stored before, in some point of accessing database resource.

What is the fact?

Upvotes: 2

Views: 1751

Answers (1)

tsolakp
tsolakp

Reputation: 5948

Yes spring transactions can timeout. You set the timeout on @Transactional annotation or <tx:method/> XML element. The default value is whatever is set on underlying transaction system such as database transaction.

For more see docs: https://docs.spring.io/spring/docs/4.2.x/spring-framework-reference/html/transaction.html

As for the details how timeout is implemented, it can vary in between Spring versions and underlying transactions used. For example when using JTA transactions the timeout is set directly on UserTransaction.

Upvotes: 1

Related Questions