[英]How to use chunk processing with Spring Batch?
I'm using Spring Batch for the first time. 我第一次使用Spring Batch。 I tried some examples and read through documentation.
我尝试了一些示例并通读了文档。 But I have still questions:
但是我仍然有疑问:
Can I skip one phase in chunk oriented processing? 我可以跳过面向块的处理中的一个阶段吗? For example: I fetch data from database, process it and determine, that I need more, can I skip write phase and execute next step's read phase?
例如:我从数据库中获取数据,对其进行处理并确定是否需要更多数据,是否可以跳过写入阶段并执行下一步的读取阶段? Should I use Tasklet instead?
我应该改用Tasklet吗?
How to implement a conditional flow? 如何实现条件流?
Thank you very much, Florian 非常感谢Florian
Skip chunks simply by throwing an exception that has been declared as "skippable exception". 只需通过抛出一个已声明为“可跳过的异常”的异常来跳过数据块 。 You can do it as follows:
您可以按照以下步骤进行操作:
<step id="step1">
<tasklet>
<chunk reader="reader" writer="writer"
commit-interval="10" skip-limit="10">
<skippable-exception-classes>
<include class="com.myapp.batch.MyException"/>
</skippable-exception-classes>
</chunk>
</tasklet>
</step>
Conditional flow can easily be implemented deciding on the ExitStatus
of a step-execution: 通过执行步骤执行的
ExitStatus
可以轻松实现条件流 :
<job id="job">
<step id="step1" parent="s1">
<next on="*" to="stepB" />
<next on="FAILED" to="stepC" />
</step>
<step id="stepB" parent="s2" next="stepC" />
<step id="stepC" parent="s3" />
</job>
Read the documentation to gain deeper knowledge on these topics: http://docs.spring.io/spring-batch/reference/html/configureStep.html 阅读文档以获取有关这些主题的更深入的知识: http : //docs.spring.io/spring-batch/reference/html/configureStep.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.