OPEN - issue BATCH-1392: Throttle limit is not parsed in ChunkElementParser

Fixed in 2.1
This commit is contained in:
dsyer
2009-09-04 12:26:41 +00:00
parent fba4cfd62f
commit 0cc77cf6ca
5 changed files with 22 additions and 12 deletions

View File

@@ -243,6 +243,10 @@ public abstract class AbstractStepParser {
RuntimeBeanReference taskExecutorRef = new RuntimeBeanReference(taskExecutorBeanId);
propertyValues.addPropertyValue("taskExecutor", taskExecutorRef);
}
String throttleLimit = taskletElement.getAttribute("throttle-limit");
if (StringUtils.hasText(throttleLimit)) {
propertyValues.addPropertyValue("throttleLimit", throttleLimit);
}
}
@SuppressWarnings("unchecked")

View File

@@ -352,6 +352,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:complexType>
<xsd:complexType name="transaction-attributesType">
@@ -585,15 +594,6 @@
]]></xsd:documentation>
</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[

View File

@@ -16,9 +16,9 @@
package org.springframework.batch.core.configuration.xml;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.ArrayList;
import java.util.HashMap;
import org.junit.Test;
@@ -125,7 +125,7 @@ public class StepParserStepFactoryBeanTests {
}
@Test(expected = IllegalStateException.class)
public void testFaultTolerantStep_All() throws Exception {
public void testFaultTolerantStepAll() throws Exception {
StepParserStepFactoryBean<Object, Object> fb = new StepParserStepFactoryBean<Object, Object>();
fb.setBeanName("step1");
fb.setAllowStartIfComplete(true);
@@ -202,13 +202,17 @@ public class StepParserStepFactoryBeanTests {
fb.setIsReaderTransactionalQueue(true);
fb.setRetryLimit(5);
fb.setSkipLimit(100);
fb.setThrottleLimit(10);
fb.setRetryListeners(new RetryListenerSupport());
fb.setSkippableExceptionClasses(new HashMap<Class<? extends Throwable>, Boolean>());
fb.setRetryableExceptionClasses(new HashMap<Class<? extends Throwable>, Boolean>());
Object step = fb.getObject();
assertTrue(step instanceof TaskletStep);
Object throttleLimit = ReflectionTestUtils.getField(ReflectionTestUtils.getField(step, "stepOperations"), "throttleLimit");
assertEquals(new Integer(10), throttleLimit);
Object tasklet = ReflectionTestUtils.getField(step, "tasklet");
assertTrue(tasklet instanceof ChunkOrientedTasklet);
}
}

View File

@@ -88,6 +88,8 @@ public class StepParserTests {
StepParserStepFactoryBean<Object, Object> factory = beans.get(factoryName);
TaskletStep bean = (TaskletStep) factory.getObject();
assertEquals("wrong start-limit:", 25, bean.getStartLimit());
Object throttleLimit = ReflectionTestUtils.getField(factory, "throttleLimit");
assertEquals(new Integer(10), throttleLimit);
}
@Test

View File

@@ -6,7 +6,7 @@
<job id="job">
<step id="step">
<tasklet start-limit="25" allow-start-if-complete="true" task-executor="taskExecutor">
<tasklet start-limit="25" allow-start-if-complete="true" task-executor="taskExecutor" throttle-limit="10">
<chunk reader="reader" processor="processor" writer="writer" commit-interval="10" skip-limit="20"
retry-limit="3" cache-capacity="100" is-reader-transactional-queue="true">
<retry-listeners>