Package org.apache.camel.processor
Class Resequencer
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.support.AsyncProcessorSupport
-
- org.apache.camel.processor.Resequencer
-
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.AsyncProcessor
,org.apache.camel.Navigate<org.apache.camel.Processor>
,org.apache.camel.Processor
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.HasId
,org.apache.camel.spi.IdAware
,org.apache.camel.spi.RouteIdAware
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
,org.apache.camel.Traceable
public class Resequencer extends org.apache.camel.support.AsyncProcessorSupport implements org.apache.camel.Navigate<org.apache.camel.Processor>, org.apache.camel.spi.IdAware, org.apache.camel.spi.RouteIdAware, org.apache.camel.Traceable
An implementation of the Resequencer which can reorder messages within a batch.
-
-
Field Summary
Fields Modifier and Type Field Description static int
DEFAULT_BATCH_SIZE
static long
DEFAULT_BATCH_TIMEOUT
-
Constructor Summary
Constructors Constructor Description Resequencer(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor processor, Set<org.apache.camel.Exchange> collection, org.apache.camel.Expression expression)
Resequencer(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor processor, org.apache.camel.Expression expression)
Resequencer(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor processor, org.apache.camel.Expression expression, boolean allowDuplicates, boolean reverse)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static Set<org.apache.camel.Exchange>
createSet(Comparator<? super org.apache.camel.Exchange> comparator, boolean allowDuplicates, boolean reverse)
protected static Set<org.apache.camel.Exchange>
createSet(org.apache.camel.Expression expression, boolean allowDuplicates, boolean reverse)
protected void
doBuild()
protected void
doInit()
protected void
doStart()
protected void
doStop()
int
getBatchSize()
long
getBatchTimeout()
org.apache.camel.Predicate
getCompletionPredicate()
org.apache.camel.spi.ExceptionHandler
getExceptionHandler()
org.apache.camel.Expression
getExpression()
String
getId()
int
getOutBatchSize()
org.apache.camel.Processor
getProcessor()
String
getRouteId()
String
getTraceLabel()
boolean
hasNext()
boolean
isAllowDuplicates()
boolean
isBatchConsumer()
boolean
isGroupExchanges()
boolean
isIgnoreInvalidExchanges()
boolean
isReverse()
List<org.apache.camel.Processor>
next()
protected void
postProcess(org.apache.camel.Exchange exchange)
boolean
process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)
Enqueues an exchange for later batch processing.protected void
processExchange(org.apache.camel.Exchange exchange)
Strategy Method to process an exchange in the batch.void
setAllowDuplicates(boolean allowDuplicates)
void
setBatchConsumer(boolean batchConsumer)
void
setBatchSize(int batchSize)
Sets the in batch size.void
setBatchTimeout(long batchTimeout)
void
setCompletionPredicate(org.apache.camel.Predicate completionPredicate)
void
setExceptionHandler(org.apache.camel.spi.ExceptionHandler exceptionHandler)
void
setGroupExchanges(boolean groupExchanges)
void
setId(String id)
void
setIgnoreInvalidExchanges(boolean ignoreInvalidExchanges)
void
setOutBatchSize(int outBatchSize)
Sets the out batch size.void
setReverse(boolean reverse)
void
setRouteId(String routeId)
String
toString()
-
Methods inherited from class org.apache.camel.support.service.BaseService
build, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
-
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
-
Resequencer
public Resequencer(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor processor, org.apache.camel.Expression expression)
-
Resequencer
public Resequencer(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor processor, org.apache.camel.Expression expression, boolean allowDuplicates, boolean reverse)
-
Resequencer
public Resequencer(org.apache.camel.CamelContext camelContext, org.apache.camel.Processor processor, Set<org.apache.camel.Exchange> collection, org.apache.camel.Expression expression)
-
-
Method Detail
-
getTraceLabel
public String getTraceLabel()
- Specified by:
getTraceLabel
in interfaceorg.apache.camel.Traceable
-
getExpression
public org.apache.camel.Expression getExpression()
-
getExceptionHandler
public org.apache.camel.spi.ExceptionHandler getExceptionHandler()
-
setExceptionHandler
public void setExceptionHandler(org.apache.camel.spi.ExceptionHandler exceptionHandler)
-
getBatchSize
public int getBatchSize()
-
setBatchSize
public void setBatchSize(int batchSize)
Sets the in batch size. This is the number of incoming exchanges that this batch processor will process before its completed. The default value isDEFAULT_BATCH_SIZE
.- Parameters:
batchSize
- the size
-
getOutBatchSize
public int getOutBatchSize()
-
setOutBatchSize
public void setOutBatchSize(int outBatchSize)
Sets the out batch size. If the batch processor holds more exchanges than this out size then the completion is triggered. Can for instance be used to ensure that this batch is completed when a certain number of exchanges has been collected. By default this feature is not enabled.- Parameters:
outBatchSize
- the size
-
getBatchTimeout
public long getBatchTimeout()
-
setBatchTimeout
public void setBatchTimeout(long batchTimeout)
-
isGroupExchanges
public boolean isGroupExchanges()
-
setGroupExchanges
public void setGroupExchanges(boolean groupExchanges)
-
isBatchConsumer
public boolean isBatchConsumer()
-
setBatchConsumer
public void setBatchConsumer(boolean batchConsumer)
-
isIgnoreInvalidExchanges
public boolean isIgnoreInvalidExchanges()
-
setIgnoreInvalidExchanges
public void setIgnoreInvalidExchanges(boolean ignoreInvalidExchanges)
-
isReverse
public boolean isReverse()
-
setReverse
public void setReverse(boolean reverse)
-
isAllowDuplicates
public boolean isAllowDuplicates()
-
setAllowDuplicates
public void setAllowDuplicates(boolean allowDuplicates)
-
getCompletionPredicate
public org.apache.camel.Predicate getCompletionPredicate()
-
setCompletionPredicate
public void setCompletionPredicate(org.apache.camel.Predicate completionPredicate)
-
getProcessor
public org.apache.camel.Processor getProcessor()
-
next
public List<org.apache.camel.Processor> next()
- Specified by:
next
in interfaceorg.apache.camel.Navigate<org.apache.camel.Processor>
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfaceorg.apache.camel.Navigate<org.apache.camel.Processor>
-
getId
public String getId()
- Specified by:
getId
in interfaceorg.apache.camel.spi.HasId
-
setId
public void setId(String id)
- Specified by:
setId
in interfaceorg.apache.camel.spi.IdAware
-
getRouteId
public String getRouteId()
- Specified by:
getRouteId
in interfaceorg.apache.camel.spi.RouteIdAware
-
setRouteId
public void setRouteId(String routeId)
- Specified by:
setRouteId
in interfaceorg.apache.camel.spi.RouteIdAware
-
createSet
protected static Set<org.apache.camel.Exchange> createSet(org.apache.camel.Expression expression, boolean allowDuplicates, boolean reverse)
-
createSet
protected static Set<org.apache.camel.Exchange> createSet(Comparator<? super org.apache.camel.Exchange> comparator, boolean allowDuplicates, boolean reverse)
-
processExchange
protected void processExchange(org.apache.camel.Exchange exchange)
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
-
postProcess
protected void postProcess(org.apache.camel.Exchange exchange)
-
doBuild
protected void doBuild() throws Exception
- Overrides:
doBuild
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doInit
protected void doInit() throws Exception
- Overrides:
doInit
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classorg.apache.camel.support.AsyncProcessorSupport
- Throws:
Exception
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classorg.apache.camel.support.AsyncProcessorSupport
- Throws:
Exception
-
process
public boolean process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)
Enqueues an exchange for later batch processing.- Specified by:
process
in interfaceorg.apache.camel.AsyncProcessor
-
-