Class ChunkTaskExecutorItemWriter<T>
- Type Parameters:
T- type of items
- All Implemented Interfaces:
org.springframework.batch.core.listener.StepExecutionListener, org.springframework.batch.core.listener.StepListener, org.springframework.batch.infrastructure.item.ItemWriter<T>
ChunkMessageChannelItemWriter, this item writer submits chunk
requests to local workers from a TaskExecutor instead of sending them over a
message channel to remote workers.
The aggregation of worker contributions is done in the afterStep method, which
waits for all worker responses and updates the step execution accordingly. If any
worker response indicates a failure, the step execution is marked as failed and the
exception is added to the step execution's failure exceptions. Otherwise, the step
execution is marked as completed and the write counts and skip counts from all worker
contributions are aggregated into the step execution's write count and write skip
count. The commit count is also incremented for each successful worker contribution,
while the rollback count is incremented for each failed worker contribution.
It should be noted that transaction management of the chunk as well as fault tolerance features are not handled by this item writer and are the responsibility of the delegate chunk processor.
Moreover, the lifecycle of the task executor is not handled by this item writer.
- Since:
- 6.0
- Author:
- Mahmoud Ben Hassine
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionChunkTaskExecutorItemWriter(org.springframework.batch.core.step.item.ChunkProcessor<T> chunkRequestProcessor, org.springframework.core.task.TaskExecutor taskExecutor) Create a newChunkTaskExecutorItemWriter. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.batch.core.ExitStatusafterStep(org.springframework.batch.core.step.StepExecution stepExecution) voidbeforeStep(org.springframework.batch.core.step.StepExecution stepExecution) void
-
Constructor Details
-
ChunkTaskExecutorItemWriter
public ChunkTaskExecutorItemWriter(org.springframework.batch.core.step.item.ChunkProcessor<T> chunkRequestProcessor, org.springframework.core.task.TaskExecutor taskExecutor) Create a newChunkTaskExecutorItemWriter.- Parameters:
chunkRequestProcessor- the chunk processor to process chunkstaskExecutor- the task executor to submit chunk processing tasks to
-
-
Method Details
-
write
-
beforeStep
public void beforeStep(org.springframework.batch.core.step.StepExecution stepExecution) - Specified by:
beforeStepin interfaceorg.springframework.batch.core.listener.StepExecutionListener
-
afterStep
public org.springframework.batch.core.ExitStatus afterStep(org.springframework.batch.core.step.StepExecution stepExecution) - Specified by:
afterStepin interfaceorg.springframework.batch.core.listener.StepExecutionListener
-