问题
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