简体   繁体   English

Spring 事务管理器调度器

[英]Spring Transaction Manager Scheduler

Good time!美好时光!

Does the Spring's transaction manager uses some kind of scheduler to invalidate transactions on timeout (if so, what is the scheduler's check period?) or there is another mechanism? Spring 的事务管理器是否使用某种调度程序在超时时使事务无效(如果是,调度程序的检查周期是多少?)还是有另一种机制?

Nope, the timeout is checked against only at database interaction, there is no separate thread to enforce it.不,仅在数据库交互时检查超时,没有单独的线程来强制执行它。 As a consequence stalled connection won't be released and the timeout exception can occur long time after actual deadline.因此,停滞的连接不会被释放,并且超时异常可能会在实际截止日期之后很长时间内发生。

If you want to make sure connections are not stuck this way, use connection pool features like c3p0's unreturnedConnectionTimeout or bonecp's closeConnectionWatch.如果您想确保连接不会以这种方式卡住,请使用连接池功能,例如 c3p0 的 unreturnedConnectionTimeout 或 bonecp 的 closeConnectionWatch。

From the Spring 3.0 docs:来自 Spring 3.0 文档:

The transaction timeout defaults to the default timeout of the underlying transaction system, or or none if timeouts are not supported事务超时默认为底层事务系统的默认超时,如果不支持超时则为无

This applies to both the @Transactional annotation and the <tx:advice> point cut.这适用于@Transactional注释和<tx:advice>切点。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM