Spring批处理条件流配置错误
Spring batch conditional flow configuration error
我有一个 XML 配置的步骤,我想添加 batch:next
元素以便在我的工作中获得条件流动:
<batch:step id="stepLoadCashFlows">
<batch:next on="*" to="stepCleanOldTrades" />
<batch:next on="FAILED" to="stepCleanCurrentTradesOnError" />
<batch:tasklet>
<batch:chunk reader="cashFlowItemReader" writer="cashFlowItemWriter"
processor="cashFlowsProcessor" commit-interval="10000" skip-limit="${cds.skip.limit}">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.integration.transformer.MessageTransformationException" />
</batch:skippable-exception-classes>
</batch:chunk>
</batch:tasklet>
<listeners>
<listener ref="cashFlowWriterListener" />
</listeners>
</batch:step>
这让我收到以下错误:
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:cpm-batch-main-cds-load.xml]
Offending resource: class path resource [cpm-dml-subscriber-cds-top-level.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 80 in XML document from class path resource [cpm-batch-main-cds-load.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 80; columnNumber: 19; cvc-complex-type.2.4.a : Invalid content found starting with element 'batch:tasklet'. One of the following values '{"http://www.springframework.org/schema/batch":next, "http://www.springframework.org/schema/batch":stop, "http://www.springframework.org/schema/batch":end, "http://www.springframework.org/schema/batch":fail, "http://www.springframework.org/schema/batch":listeners}' is expected.
那么我应该把它们放在哪里(我在步骤结束时试过,在 tasklet 中...)?
transitions 元素应该放在 tasklet
元素之后。所以在你的情况下,以下应该有效:
<batch:step id="stepLoadCashFlows">
<batch:tasklet>
<batch:chunk reader="cashFlowItemReader" writer="cashFlowItemWriter"
processor="cashFlowsProcessor" commit-interval="10000" skip-limit="${cds.skip.limit}">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.integration.transformer.MessageTransformationException" />
</batch:skippable-exception-classes>
</batch:chunk>
<batch:listeners>
<batch:listener ref="cashFlowWriterListener" />
</batch:listeners>
</batch:tasklet>
<batch:next on="*" to="stepCleanOldTrades" />
<batch:next on="FAILED" to="stepCleanCurrentTradesOnError" />
</batch:step>
请注意,listeners
元素应位于 tasklet
元素内。
我有一个 XML 配置的步骤,我想添加 batch:next
元素以便在我的工作中获得条件流动:
<batch:step id="stepLoadCashFlows">
<batch:next on="*" to="stepCleanOldTrades" />
<batch:next on="FAILED" to="stepCleanCurrentTradesOnError" />
<batch:tasklet>
<batch:chunk reader="cashFlowItemReader" writer="cashFlowItemWriter"
processor="cashFlowsProcessor" commit-interval="10000" skip-limit="${cds.skip.limit}">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.integration.transformer.MessageTransformationException" />
</batch:skippable-exception-classes>
</batch:chunk>
</batch:tasklet>
<listeners>
<listener ref="cashFlowWriterListener" />
</listeners>
</batch:step>
这让我收到以下错误:
Caused by: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Failed to import bean definitions from URL location [classpath:cpm-batch-main-cds-load.xml]
Offending resource: class path resource [cpm-dml-subscriber-cds-top-level.xml]; nested exception is org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 80 in XML document from class path resource [cpm-batch-main-cds-load.xml] is invalid; nested exception is org.xml.sax.SAXParseException; lineNumber: 80; columnNumber: 19; cvc-complex-type.2.4.a : Invalid content found starting with element 'batch:tasklet'. One of the following values '{"http://www.springframework.org/schema/batch":next, "http://www.springframework.org/schema/batch":stop, "http://www.springframework.org/schema/batch":end, "http://www.springframework.org/schema/batch":fail, "http://www.springframework.org/schema/batch":listeners}' is expected.
那么我应该把它们放在哪里(我在步骤结束时试过,在 tasklet 中...)?
transitions 元素应该放在 tasklet
元素之后。所以在你的情况下,以下应该有效:
<batch:step id="stepLoadCashFlows">
<batch:tasklet>
<batch:chunk reader="cashFlowItemReader" writer="cashFlowItemWriter"
processor="cashFlowsProcessor" commit-interval="10000" skip-limit="${cds.skip.limit}">
<batch:skippable-exception-classes>
<batch:include class="org.springframework.integration.transformer.MessageTransformationException" />
</batch:skippable-exception-classes>
</batch:chunk>
<batch:listeners>
<batch:listener ref="cashFlowWriterListener" />
</batch:listeners>
</batch:tasklet>
<batch:next on="*" to="stepCleanOldTrades" />
<batch:next on="FAILED" to="stepCleanCurrentTradesOnError" />
</batch:step>
请注意,listeners
元素应位于 tasklet
元素内。