Class SynchronizedItemWriter<T>

java.lang.Object
org.springframework.batch.item.support.SynchronizedItemWriter<T>
Type Parameters:
T - type of objects to write
All Implemented Interfaces:
ItemWriter<T>

public class SynchronizedItemWriter<T> extends Object implements ItemWriter<T>
This is an ItemWriter decorator with a synchronized ItemWriter.write(org.springframework.batch.item.Chunk<? extends T>) method. This decorator is useful when using a non thread-safe item writer in a multi-threaded step.
Since:
5.1.0
Author:
Mahmoud Ben Hassine
  • Constructor Details

    • SynchronizedItemWriter

      public SynchronizedItemWriter(ItemWriter<T> delegate)
  • Method Details

    • write

      public void write(Chunk<? extends T> items) throws Exception
      This method delegates to the write method of the delegate and is synchronized with a lock.
      Specified by:
      write in interface ItemWriter<T>
      Parameters:
      items - of items to be written. Must not be null.
      Throws:
      Exception - if there are errors. The framework will catch the exception and convert or rethrow it as appropriate.