org.springframework.batch.integration.chunk
Class ChunkMessageChannelItemWriter

java.lang.Object
  extended by org.springframework.batch.core.listener.StepExecutionListenerSupport
      extended by org.springframework.batch.integration.chunk.ChunkMessageChannelItemWriter
All Implemented Interfaces:
StepExecutionListener, StepListener, ItemStream, ItemWriter

public class ChunkMessageChannelItemWriter
extends StepExecutionListenerSupport
implements ItemWriter, ItemStream


Constructor Summary
ChunkMessageChannelItemWriter()
           
 
Method Summary
 ExitStatus afterStep(StepExecution stepExecution)
          Give a listener a chance to modify the exit status from a step.
 void beforeStep(StepExecution stepExecution)
          Initialise the state of the listener with the StepExecution from the current scope.
 void clear()
          Clear the buffer.
 void close(ExecutionContext executionContext)
          If any resources are needed for the stream to operate they need to be destroyed here.
 void flush()
          Flush the buffer, sending the items as a chunk message to be processed by a ChunkHandler.
 void open(ExecutionContext executionContext)
          Open the stream for the provided ExecutionContext.
 void setReplyChannel(org.springframework.integration.channel.MessageChannel replyChannel)
           
 void setRequestChannel(org.springframework.integration.channel.MessageChannel requestChannel)
           
 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(Object item)
          Process the supplied data element.
 
Methods inherited from class org.springframework.batch.core.listener.StepExecutionListenerSupport
onErrorInStep
 
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

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

setReplyChannel

public void setReplyChannel(org.springframework.integration.channel.MessageChannel replyChannel)

setRequestChannel

public void setRequestChannel(org.springframework.integration.channel.MessageChannel requestChannel)

write

public void write(Object item)
           throws Exception
Description copied from interface: ItemWriter
Process the supplied data element. Will be called multiple times during a larger batch operation. Will not be called with null data in normal operation.

Specified by:
write in interface ItemWriter
Throws:
Exception - if there are errors. If the writer is used inside a retry or a batch the framework will catch the exception and convert or rethrow it as appropriate.

flush

public void flush()
           throws FlushFailedException
Flush the buffer, sending the items as a chunk message to be processed by a ChunkHandler. To avoid overwhelming the receivers, this method will block until the number of chunks pending is less than the throttle limit.

Specified by:
flush in interface ItemWriter
Throws:
FlushFailedException - in case of an error. If this exception is thrown the writer may be in an inconsistent state and manual intervention might be required to reconcile the data with persistent output.
See Also:
ItemWriter.flush()

beforeStep

public void beforeStep(StepExecution stepExecution)
Description copied from interface: StepExecutionListener
Initialise 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 successful execution of step's processing logic. Throwing exception in this method will cause step to fail.

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(ExecutionContext executionContext)
           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
Parameters:
executionContext - the current execution context in case it is needed
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
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

clear

public void clear()
           throws ClearFailedException
Clear the buffer.

Specified by:
clear in interface ItemWriter
Throws:
ClearFailedException - in case of an error. If this exception is thrown the writer may be in an inconsistent state and manual intervention might be required to reconcile the data with persistent output.
See Also:
ItemWriter.clear()


Copyright © 2009 SpringSource. All Rights Reserved.