【发布时间】:2011-10-15 22:15:19
【问题描述】:
我正在使用 Spring Batch 设置一个作业,该作业将处理一个可能非常大的 XML 文件。我想我已经适当地设置了它,但是在运行时我发现作业运行,处理它的输入,然后只是挂在执行状态(我可以通过查看 JobRepository 中的 JobExecution 的状态来确认)。
我已多次阅读 Batch 文档,但没有看到任何明显的“输入不足时停止作业”配置。
这是我的应用程序上下文的相关部分:
<batch:job id="processPartnerUploads" restartable="true">
<batch:step id="processStuffHoldings">
<batch:tasklet>
<batch:chunk reader="stuffReader" writer="stuffWriter" commit-interval="1"/>
</batch:tasklet>
</batch:step>
</batch:job>
<bean id="stuffReader" class="org.springframework.batch.item.xml.StaxEventItemReader">
<property name="fragmentRootElementName" value="stuff" />
<property name="resource" value="file:///path/to/file.xml" />
<property name="unmarshaller" ref="stuffUnmarshaller" />
</bean>
<bean id="stuffUnmarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="contextPath" value="com.company.project.xmlcontext"/>
</bean>
<bean id="stuffWriter" class="com.company.project.batch.StuffWriter" />
如果重要的话,“StuffWriter”只是一个记录要写入的项目的类。
如果我遗漏了与 Batch 和/或 Stax 相关的一些重要细微差别,请告诉我。
【问题讨论】:
-
您可以添加您正在尝试使用的 xml 文件吗?即使是小文件也会发生这种情况吗?您能否为 Spring Batch 启用信息/调试日志记录并发布相关部分。
-
我不得不离开这个问题几天,然后再回来解决这个问题。我们的 XML 文件非常基本,很像 Spring Batch 文档中的示例,其中
包含多个子 元素。
标签: xml spring jaxb spring-batch stax