I have a spring batch application which reads records from DB table and makes REST API calls in the writer class to get the data to be cached. However I observe that not all threads from the thread pool are running. They just run in the batches of 4-5 due which application takes 5 hours to make 120K calls. Following is the spring batch context
Task Executor:
<bean id="myTaskExecutor"
class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor">
<property name="corePoolSize" value="20"/>
<property name="maxPoolSize" value="20"/>
</bean>
Batch Job:
<batch:job id="myBatchJob">
<batch:step id="loadData">
<batch:tasklet task-executor="myTaskExecutor"
transaction-manager="batchTransactionManager">
<batch:chunk reader="myReader" writer="myLoader"
commit-interval="250">
</batch:chunk>
<batch:listeners>
<batch:listener ref="batchStepListener" />
</batch:listeners>
</batch:tasklet>
</batch:step>
</batch:job>
Reader config: Note that the dataSource has 20 min/max connections
<batch:job id="myBatchJob">
<batch:step id="loadLei">
<batch:tasklet task-executor="myTaskExecutor"
transaction-manager="batchTransactionManager">
<batch:chunk reader="myReader" writer="myLoader"
commit-interval="250">
</batch:chunk>
<batch:listeners>
<batch:listener ref="batchStepListener" />
</batch:listeners>
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="myReader"
class="org.springframework.batch.item.database.JdbcPagingItemReader">
<property name="dataSource" ref="myDataSource" />
<property name="queryProvider" ref="myQueryProvider" />
<property name="pageSize" value="1000" />
<property name="rowMapper" ref="myRowMapper" />
<property name="saveState" value="false" />
</bean>
<bean id="myQueryProvider"
class="org.springframework.batch.item.database.support.SqlPagingQueryProviderFactoryBean">
<property name="dataSource" ref="myDataSource" />
<property name="selectClause" value="SELECT * " />
<property name="fromClause" value="MYTABLE"/>
<property name="sortKeys">
<map>
<entry key="MYCOLUMN" value="ASCENDING"></entry>
</map>
</property>
</bean>
<bean id="myRowMapper"
class="com.my.RequestRowMapper">
</bean>