org.springframework.batch.integration.chunk

## Class ChunkMessageChannelItemWriter<T>

- java.lang.Object
- - org.springframework.batch.core.listener.StepExecutionListenerSupport
  - - org.springframework.batch.integration.chunk.ChunkMessageChannelItemWriter<T>

- All Implemented Interfaces:
    StepExecutionListener, StepListener, StepContributionSource, ItemStream, ItemWriter<T>

      public class ChunkMessageChannelItemWriter<T>
      extends StepExecutionListenerSupport
      implements ItemWriter<T>, ItemStream, StepContributionSource

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ChunkMessageChannelItemWriter()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ExitStatus` | `afterStep(StepExecution stepExecution)` Give a listener a chance to modify the exit status from a step.
    `void` | `beforeStep(StepExecution stepExecution)` Initialize the state of the listener with the `StepExecution` from the current scope.
    `void` | `close()` If any resources are needed for the stream to operate they need to be destroyed here.
    `java.util.Collection<StepContribution>` | `getStepContributions()` Get the currently available contributions and drain the source.
    `void` | `open(ExecutionContext executionContext)` Open the stream for the provided `ExecutionContext`.
    `void` | `setMaxWaitTimeouts(int maxWaitTimeouts)` The maximum number of times to wait at the end of a step for a non-null result from the remote workers.
    `void` | `setMessagingOperations(org.springframework.integration.core.MessagingTemplate messagingGateway)`
    `void` | `setReplyChannel(org.springframework.messaging.PollableChannel replyChannel)`
    `void` | `setThrottleLimit(long throttleLimit)` Public setter for the throttle limit.
    `void` | `update(ExecutionContext executionContext)` Indicates that the execution context provided during open is about to be saved.
    `void` | `write(java.util.List<? extends T> items)` Process the supplied data element.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ChunkMessageChannelItemWriter

          public ChunkMessageChannelItemWriter()

  - ### Method Detail

    - #### setMaxWaitTimeouts

          public void setMaxWaitTimeouts(int maxWaitTimeouts)

      The maximum number of times to wait at the end of a step for a non-null result from the remote workers. This is a multiplier on the receive timeout set separately on the gateway. The ideal value is a compromise between allowing slow workers time to finish, and responsiveness if there is a dead worker. Defaults to 40.
      Parameters:
        `maxWaitTimeouts` - the maximum number of wait timeouts

    - #### setThrottleLimit

          public void setThrottleLimit(long throttleLimit)

      Public setter for the throttle limit. This limits the number of pending requests for chunk processing to avoid overwhelming the receivers.
      Parameters:
        `throttleLimit` - the throttle limit to set

    - #### setMessagingOperations

          public void setMessagingOperations(org.springframework.integration.core.MessagingTemplate messagingGateway)

    - #### setReplyChannel

          public void setReplyChannel(org.springframework.messaging.PollableChannel replyChannel)

    - #### write

          public void write(java.util.List<? extends T> items)
                     throws java.lang.Exception

      Description copied from interface: `ItemWriter`
      Process the supplied data element. Will not be called with any null items in normal operation.
      Specified by:
        `write` in interface `ItemWriter<T>`
      Parameters:
        `items` - items to be written
      Throws:
        `java.lang.Exception` - if there are errors. The framework will catch the exception and convert or rethrow it as appropriate.

    - #### beforeStep

          public void beforeStep(StepExecution stepExecution)

      Description copied from interface: `StepExecutionListener`
      Initialize the state of the listener with the `StepExecution` from the current scope.
      Specified by:
        `beforeStep` in interface `StepExecutionListener`
      Overrides:
        `beforeStep` in class `StepExecutionListenerSupport`

    - #### afterStep

          public ExitStatus afterStep(StepExecution stepExecution)

      Description copied from interface: `StepExecutionListener`
      Give a listener a chance to modify the exit status from a step. The value returned will be combined with the normal exit status using `ExitStatus.and(ExitStatus)`. Called after execution of step's processing logic (both successful or failed). Throwing exception in this method has no effect, it will only be logged.
      Specified by:
        `afterStep` in interface `StepExecutionListener`
      Overrides:
        `afterStep` in class `StepExecutionListenerSupport`
      Returns:
        an `ExitStatus` to combine with the normal value. Return null to leave the old value unchanged.

    - #### close

          public void close()
                     throws ItemStreamException

      Description copied from interface: `ItemStream`
      If any resources are needed for the stream to operate they need to be destroyed here. Once this method has been called all other methods (except open) may throw an exception.
      Specified by:
        `close` in interface `ItemStream`
      Throws:
        `ItemStreamException`

    - #### open

          public void open(ExecutionContext executionContext)
                    throws ItemStreamException

      Description copied from interface: `ItemStream`
      Open the stream for the provided `ExecutionContext`.
      Specified by:
        `open` in interface `ItemStream`
      Parameters:
        `executionContext` - current step's `ExecutionContext`. Will be the executionContext from the last run of the step on a restart.
      Throws:
        `ItemStreamException`

    - #### update

          public void update(ExecutionContext executionContext)
                      throws ItemStreamException

      Description copied from interface: `ItemStream`
      Indicates that the execution context provided during open is about to be saved. If any state is remaining, but has not been put in the context, it should be added here.
      Specified by:
        `update` in interface `ItemStream`
      Parameters:
        `executionContext` - to be updated
      Throws:
        `ItemStreamException`

    - #### getStepContributions

          public java.util.Collection<StepContribution> getStepContributions()

      Description copied from interface: `StepContributionSource`
      Get the currently available contributions and drain the source. The next call would return an empty collection, unless new contributions have arrived.
      Specified by:
        `getStepContributions` in interface `StepContributionSource`
      Returns:
        a collection of `StepContribution` instances