当使用带有AsyncItemWriter的FlatFileItemWriter作为委托时,我得到WriterNotOpenException:
<bean id="partFile" class="org.springframework.core.io.FileSystemResource" scope="step">
<constructor-arg value="#{stepExecutionContext[resourceName]}" />
</bean>
<bean id="partItemWriter" class="org.springframework.batch.item.file.FlatFileItemWriter"
parent="abstractFlatFileItemWriter" scope="step">
<property name="resource" ref="partFile" />
</bean>
<bean id="partItemWriterAsync" class="org.springframework.batch.integration.async.AsyncItemWriter">
<property name="delegate" ref="partItemWriter" />
</bean><batch:step id="partFeedGenerationStep">
<batch:tasklet>
<batch:chunk reader="partItemReader"
processor="partItemProcessorAsync"
writer="parttemWriterAsync" commit-interval="10" />
</batch:step>
如果我在同步模式下按步骤
执行相同步骤,则该步骤正常<batch:step id="partitionFeedGenerationStep">
<batch:tasklet>
<batch:chunk reader="rwaPartitionCachePaginatedItemReader"
processor="rwaRsCompositeItemProcessor"
writer="parItemWriter" commit-interval="10" />
</batch:step>
例外: AbstractStep在job etl.dstream.optima.rwa.MasterJob [SimpleAsyncTaskExecutor-6]中遇到执行步骤partFeedGenerationStep的错误 org.springframework.batch.item.WriterNotOpenException:Writer必须先打开才能写入 在org.springframework.batch.item.file.FlatFileItemWriter.write(FlatFileItemWriter.java:255)
有任何解决此问题的建议吗?
答案 0 :(得分:0)
在spring-batch-integration中,v3.x AsyncItemWriter
实现了ItemWriter
,而不是ItemStreamWriter
,因此它与FlatFileItemWriter
不兼容。这个问题已在v4.x中修复,但实际上只有v4.0.0.M3可用,所以我从github那里得到了the source of AsyncItemWriter
并将其添加到我的源代码中。有用。当一个明确的v4.x可用时,我将升级并删除&#34; custom&#34;类。