Does Spring-batch acquires connections from datasource for whole job running time?

旧巷老猫 提交于 2019-12-11 06:41:55

问题


Does Spring-batch acquires connections from datasource for whole job running time?

In general I have long running steps in Spring-batch job. During execution Springs takes connection from datasource managed by C3P0 and when steps runs too long C3P0 collects this connections by unreturnedConnectionTimeout - which prevents Springs to finish its manipulations with DB.

In order to manage this I am considering to refactor long running tasklet steps to chunk oriented with hope that Spring acquire connection from datasource only for period not longer than step execution or chunk processing time. And if Springs acquires connection for whole job - this refactoring will not help.


回答1:


Spring Batch obtains connections in a number of different points for a number of different reasons so with the information you've provided, I can't clearly answer the exact question you are having. That being said, if you have long running chunks or tasklets, each of those are executed within the scope of a single transaction and therefore need to be tied to a single connection.



来源:https://stackoverflow.com/questions/27342094/does-spring-batch-acquires-connections-from-datasource-for-whole-job-running-tim

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!