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
Modifier and TypeFieldDescriptionstatic final int
static final long
Fields inherited from class org.apache.camel.support.service.BaseService
BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
-
Constructor Summary
ConstructorDescriptionResequencer
(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
Modifier and TypeMethodDescriptionprotected 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
long
org.apache.camel.Predicate
org.apache.camel.spi.ExceptionHandler
org.apache.camel.Expression
getId()
int
org.apache.camel.Processor
boolean
hasNext()
boolean
boolean
boolean
boolean
boolean
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
void
setIgnoreInvalidExchanges
(boolean ignoreInvalidExchanges) void
setOutBatchSize
(int outBatchSize) Sets the out batch size.void
setReverse
(boolean reverse) void
setRouteId
(String routeId) toString()
Methods inherited from class org.apache.camel.support.AsyncProcessorSupport
process, processAsync
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
Methods inherited from interface org.apache.camel.spi.IdAware
setGeneratedId
Methods inherited from interface org.apache.camel.Service
build, close, init, start, stop
Methods inherited from interface org.apache.camel.ShutdownableService
shutdown
Methods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
Methods inherited from interface org.apache.camel.SuspendableService
isSuspended, resume, suspend
-
Field Details
-
DEFAULT_BATCH_TIMEOUT
public static final long DEFAULT_BATCH_TIMEOUT- See Also:
-
DEFAULT_BATCH_SIZE
public static final int DEFAULT_BATCH_SIZE- See Also:
-
-
Constructor Details
-
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 Details
-
toString
-
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
- 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
- Specified by:
getId
in interfaceorg.apache.camel.spi.HasId
-
setId
- Specified by:
setId
in interfaceorg.apache.camel.spi.IdAware
-
getRouteId
- Specified by:
getRouteId
in interfaceorg.apache.camel.spi.RouteIdAware
-
setRouteId
- 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
- Overrides:
doBuild
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doInit
- Overrides:
doInit
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStart
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.service.BaseService
- 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
-