Class ChunkTaskExecutorItemWriter<T>

java.lang.Object
org.springframework.batch.integration.chunk.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>

public class ChunkTaskExecutorItemWriter<T> extends Object implements org.springframework.batch.infrastructure.item.ItemWriter<T>, org.springframework.batch.core.listener.StepExecutionListener
Similar to 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

    Constructors
    Constructor
    Description
    ChunkTaskExecutorItemWriter(org.springframework.batch.core.step.item.ChunkProcessor<T> chunkRequestProcessor, org.springframework.core.task.TaskExecutor taskExecutor)
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.batch.core.ExitStatus
    afterStep(org.springframework.batch.core.step.StepExecution stepExecution)
     
    void
    beforeStep(org.springframework.batch.core.step.StepExecution stepExecution)
     
    void
    write(org.springframework.batch.infrastructure.item.Chunk<? extends T> chunk)
     

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ChunkTaskExecutorItemWriter

      public ChunkTaskExecutorItemWriter(org.springframework.batch.core.step.item.ChunkProcessor<T> chunkRequestProcessor, org.springframework.core.task.TaskExecutor taskExecutor)
      Parameters:
      chunkRequestProcessor - the chunk processor to process chunks
      taskExecutor - the task executor to submit chunk processing tasks to
  • Method Details

    • write

      public void write(org.springframework.batch.infrastructure.item.Chunk<? extends T> chunk)
      Specified by:
      write in interface org.springframework.batch.infrastructure.item.ItemWriter<T>
    • beforeStep

      public void beforeStep(org.springframework.batch.core.step.StepExecution stepExecution)
      Specified by:
      beforeStep in interface org.springframework.batch.core.listener.StepExecutionListener
    • afterStep

      public org.springframework.batch.core.ExitStatus afterStep(org.springframework.batch.core.step.StepExecution stepExecution)
      Specified by:
      afterStep in interface org.springframework.batch.core.listener.StepExecutionListener