Class AsyncItemWriter<T>

java.lang.Object
org.springframework.batch.integration.async.AsyncItemWriter<T>
All Implemented Interfaces:
org.springframework.batch.infrastructure.item.ItemStream, org.springframework.batch.infrastructure.item.ItemStreamWriter<Future<T>>, org.springframework.batch.infrastructure.item.ItemWriter<Future<T>>

public class AsyncItemWriter<T> extends Object implements org.springframework.batch.infrastructure.item.ItemStreamWriter<Future<T>>
  • Constructor Summary

    Constructors
    Constructor
    Description
    AsyncItemWriter(org.springframework.batch.infrastructure.item.ItemWriter<T> delegate)
    Create a new instance of AsyncItemWriter with the provided delegate.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    open(org.springframework.batch.infrastructure.item.ExecutionContext executionContext)
     
    void
    setDelegate(org.springframework.batch.infrastructure.item.ItemWriter<T> delegate)
     
    void
    update(org.springframework.batch.infrastructure.item.ExecutionContext executionContext)
     
    void
    write(org.springframework.batch.infrastructure.item.Chunk<? extends Future<T>> items)
    In the processing of the Futures passed, nulls are not passed to the delegate since they are considered filtered out by the AsyncItemProcessor's delegated ItemProcessor.

    Methods inherited from class Object

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

    • AsyncItemWriter

      public AsyncItemWriter(org.springframework.batch.infrastructure.item.ItemWriter<T> delegate)
      Create a new instance of AsyncItemWriter with the provided delegate.
      Parameters:
      delegate - the delegate item writer
      Since:
      6.0
  • Method Details

    • setDelegate

      public void setDelegate(org.springframework.batch.infrastructure.item.ItemWriter<T> delegate)
      Parameters:
      delegate - ItemWriter that does the actual writing of the Future results
    • write

      public void write(org.springframework.batch.infrastructure.item.Chunk<? extends Future<T>> items) throws Exception
      In the processing of the Futures passed, nulls are not passed to the delegate since they are considered filtered out by the AsyncItemProcessor's delegated ItemProcessor. If the unwrapping of the Future results in an ExecutionException, that will be unwrapped and the cause will be thrown.
      Specified by:
      write in interface org.springframework.batch.infrastructure.item.ItemWriter<T>
      Parameters:
      items - Futures to be unwrapped and passed to the delegate
      Throws:
      Exception - The exception returned by the Future if one was thrown
    • open

      public void open(org.springframework.batch.infrastructure.item.ExecutionContext executionContext) throws org.springframework.batch.infrastructure.item.ItemStreamException
      Specified by:
      open in interface org.springframework.batch.infrastructure.item.ItemStream
      Throws:
      org.springframework.batch.infrastructure.item.ItemStreamException
    • update

      public void update(org.springframework.batch.infrastructure.item.ExecutionContext executionContext) throws org.springframework.batch.infrastructure.item.ItemStreamException
      Specified by:
      update in interface org.springframework.batch.infrastructure.item.ItemStream
      Throws:
      org.springframework.batch.infrastructure.item.ItemStreamException
    • close

      public void close() throws org.springframework.batch.infrastructure.item.ItemStreamException
      Specified by:
      close in interface org.springframework.batch.infrastructure.item.ItemStream
      Throws:
      org.springframework.batch.infrastructure.item.ItemStreamException