org.apache.camel.processor
Class BatchProcessor

java.lang.Object
  extended by org.apache.camel.impl.ServiceSupport
      extended by org.apache.camel.processor.BatchProcessor
All Implemented Interfaces:
Runnable, Service
Direct Known Subclasses:
Aggregator, Resequencer

public class BatchProcessor
extends ServiceSupport
implements Runnable

A base class for any kind of Processor which implements some kind of batch processing.

Version:
$Revision: 35332 $

Field Summary
static int DEFAULT_BATCH_SIZE
           
static long DEFAULT_BATCH_TIMEOUT
           
 
Constructor Summary
BatchProcessor(Endpoint endpoint, Processor processor, Collection<Exchange> collection)
           
 
Method Summary
protected  void doStart()
           
protected  void doStop()
           
 int getBatchSize()
           
 long getBatchTimeout()
           
protected  Collection<Exchange> getCollection()
           
 Endpoint getEndpoint()
           
 ExceptionHandler getExceptionHandler()
           
 Processor getProcessor()
           
protected  boolean isBatchCompleted(int index)
          A strategy method to decide if the batch is completed the resulting exchanges should be sent
protected  void processBatch()
          A transactional method to process a batch of messages up to a timeout period or number of messages reached.
protected  void processExchange(Exchange exchange)
          Strategy Method to process an exchange in the batch.
 void run()
           
 void setBatchSize(int batchSize)
           
 void setBatchTimeout(long batchTimeout)
           
 void setExceptionHandler(ExceptionHandler exceptionHandler)
           
 String toString()
           
 
Methods inherited from class org.apache.camel.impl.ServiceSupport
addChildService, getThreadName, isRunAllowed, isStarted, isStarting, isStopped, isStopping, nextThreadCounter, removeChildService, start, stop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_BATCH_TIMEOUT

public static final long DEFAULT_BATCH_TIMEOUT
See Also:
Constant Field Values

DEFAULT_BATCH_SIZE

public static final int DEFAULT_BATCH_SIZE
See Also:
Constant Field Values
Constructor Detail

BatchProcessor

public BatchProcessor(Endpoint endpoint,
                      Processor processor,
                      Collection<Exchange> collection)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

run

public void run()
Specified by:
run in interface Runnable

getExceptionHandler

public ExceptionHandler getExceptionHandler()

setExceptionHandler

public void setExceptionHandler(ExceptionHandler exceptionHandler)

getBatchSize

public int getBatchSize()

setBatchSize

public void setBatchSize(int batchSize)

getBatchTimeout

public long getBatchTimeout()

setBatchTimeout

public void setBatchTimeout(long batchTimeout)

getEndpoint

public Endpoint getEndpoint()

getProcessor

public Processor getProcessor()

processBatch

protected void processBatch()
                     throws Exception
A transactional method to process a batch of messages up to a timeout period or number of messages reached.

Throws:
Exception

isBatchCompleted

protected boolean isBatchCompleted(int index)
A strategy method to decide if the batch is completed the resulting exchanges should be sent


processExchange

protected void processExchange(Exchange exchange)
                        throws Exception
Strategy Method to process an exchange in the batch. This method allows derived classes to perform custom processing before or after an individual exchange is processed

Throws:
Exception

doStart

protected void doStart()
                throws Exception
Specified by:
doStart in class ServiceSupport
Throws:
Exception

doStop

protected void doStop()
               throws Exception
Specified by:
doStop in class ServiceSupport
Throws:
Exception

getCollection

protected Collection<Exchange> getCollection()


Copyright © 2008 IONA Open Source Community. All Rights Reserved.