BATCH-1216: Add throttle-limit to <chunk/>
This commit is contained in:
@@ -34,6 +34,7 @@ import org.springframework.batch.item.ItemStream;
|
||||
import org.springframework.batch.item.ItemWriter;
|
||||
import org.springframework.batch.repeat.CompletionPolicy;
|
||||
import org.springframework.batch.repeat.policy.SimpleCompletionPolicy;
|
||||
import org.springframework.batch.repeat.support.TaskExecutorRepeatTemplate;
|
||||
import org.springframework.batch.retry.RetryListener;
|
||||
import org.springframework.batch.retry.policy.MapRetryContextCache;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
@@ -108,6 +109,8 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
|
||||
|
||||
private TaskExecutor taskExecutor;
|
||||
|
||||
private Integer throttleLimit;
|
||||
|
||||
private ItemReader<? extends I> itemReader;
|
||||
|
||||
private ItemProcessor<? super I, ? extends O> itemProcessor;
|
||||
@@ -204,6 +207,9 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
|
||||
if (taskExecutor != null) {
|
||||
fb.setTaskExecutor(taskExecutor);
|
||||
}
|
||||
if (throttleLimit != null) {
|
||||
fb.setThrottleLimit(throttleLimit);
|
||||
}
|
||||
if (itemReader != null) {
|
||||
fb.setItemReader(itemReader);
|
||||
}
|
||||
@@ -574,6 +580,18 @@ class StepParserStepFactoryBean<I, O> implements FactoryBean, BeanNameAware {
|
||||
this.taskExecutor = taskExecutor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Public setter for the throttle limit. This limits the number of tasks
|
||||
* queued for concurrent processing to prevent thread pools from being
|
||||
* overwhelmed. Defaults to
|
||||
* {@link TaskExecutorRepeatTemplate#DEFAULT_THROTTLE_LIMIT}.
|
||||
*
|
||||
* @param throttleLimit the throttle limit to set.
|
||||
*/
|
||||
public void setThrottleLimit(Integer throttleLimit) {
|
||||
this.throttleLimit = throttleLimit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param itemReader the {@link ItemReader} to set
|
||||
*/
|
||||
|
||||
@@ -567,6 +567,15 @@
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="throttle-limit" type="xsd:string" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation><![CDATA[
|
||||
This limits the number of tasks queued for concurrent
|
||||
processing to prevent thread pools from being overwhelmed.
|
||||
Default is 4.
|
||||
]]></xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="chunk-completion-policy" type="xsd:string" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation source="java:org.springframework.batch.repeat.CompletionPolicy"><![CDATA[
|
||||
|
||||
Reference in New Issue
Block a user