Class ChunkTaskExecutorItemWriter<T>
- Type Parameters:
T- type of items
- All Implemented Interfaces:
StepExecutionListener, StepListener, 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(ChunkProcessor<T> chunkRequestProcessor, org.springframework.core.task.TaskExecutor taskExecutor) Create a newChunkTaskExecutorItemWriter. -
Method Summary
Modifier and TypeMethodDescriptionafterStep(StepExecution stepExecution) Give a listener a chance to modify the exit status from a step.voidbeforeStep(StepExecution stepExecution) Initialize the state of the listener with theStepExecutionfrom the current scope.voidProcess the supplied data element.
-
Constructor Details
-
ChunkTaskExecutorItemWriter
public ChunkTaskExecutorItemWriter(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
Description copied from interface:ItemWriterProcess the supplied data element. Will not be called with any null items in normal operation but might be called with an empty chunk, for example when all items have been filtered by anItemProcessoror skipped by the fault-tolerant step processing. Implementations are expected to handle empty chunks gracefully.- Specified by:
writein interfaceItemWriter<T>- Parameters:
chunk- of items to be written. Nevernullbut may be empty.
-
beforeStep
Description copied from interface:StepExecutionListenerInitialize the state of the listener with theStepExecutionfrom the current scope.- Specified by:
beforeStepin interfaceStepExecutionListener- Parameters:
stepExecution- instance ofStepExecution.
-
afterStep
Description copied from interface:StepExecutionListenerGive a listener a chance to modify the exit status from a step. The value returned is combined with the normal exit status by usingExitStatus.and(ExitStatus).Called after execution of the step's processing logic (whether successful or failed). Throwing an exception in this method has no effect, as it is only logged.
- Specified by:
afterStepin interfaceStepExecutionListener- Parameters:
stepExecution- aStepExecutioninstance.- Returns:
- an
ExitStatusto combine with the normal value. Returnnull(the default) to leave the old value unchanged.
-