开发者

Do we have ChunkExecutionContext similar to StepExecutionContext in Spring Batch?

开发者 https://www.devze.com 2023-04-02 13:45 出处:网络
Spring Batch Version: 2.1.8 We want to do something after each chunk is written, and set some data inside a context which is valid only for the chunk. This data is then used inside ChunkListener\'s
Spring Batch Version: 2.1.8

We want to do something after each chunk is written, and set some data inside a context which is valid only for the chunk. This data is then used inside ChunkListener's afterChunk method.

We can use StepExecutionContext to achieve this, but didn't seem totally correct.

开发者_运维百科Does anyone have more information on where to store context information valid only for a chunk?


There is in fact a ChunkContext available in Spring Batch 2.1.8. To understand the lifecycle of the ChunkContext it's important to understand that the chunk is defined by the commit-interval of the Tasklet. The Tasklet is responsible for managing the lifecycle of the ChunkContext. Also see the java docs for the ChunkContext for a note about retries.

The ChunkContext is accessible through the the JobExecutionContext getChunContexts()

0

精彩评论

暂无评论...
验证码 换一张
取 消