public class AggregateProcessor
extends org.apache.camel.support.AsyncProcessorSupport
implements org.apache.camel.Navigate<org.apache.camel.Processor>, org.apache.camel.Traceable, org.apache.camel.spi.ShutdownPrepared, org.apache.camel.spi.ShutdownAware, org.apache.camel.spi.IdAware
AggregationStrategy
(by default the latest message is used) to compress many message exchanges
into a smaller number of exchanges.
A good example of this is stock market data; you may be receiving 30,000
messages/second and you may want to throttle it right down so that multiple
messages for the same stock are combined (or just the latest message is used
and older prices are discarded). Another idea is to combine line item messages
together into a single invoice message.Modifier and Type | Field and Description |
---|---|
static String |
AGGREGATE_OPTIMISTIC_LOCKING_EXECUTOR |
static String |
AGGREGATE_TIMEOUT_CHECKER |
static String |
COMPLETED_BY_CONSUMER |
static String |
COMPLETED_BY_FORCE |
static String |
COMPLETED_BY_INTERVAL |
static String |
COMPLETED_BY_PREDICATE |
static String |
COMPLETED_BY_SIZE |
static String |
COMPLETED_BY_STRATEGY |
static String |
COMPLETED_BY_TIMEOUT |
Constructor and Description |
---|
AggregateProcessor(org.apache.camel.CamelContext camelContext,
org.apache.camel.AsyncProcessor processor,
org.apache.camel.Expression correlationExpression,
org.apache.camel.AggregationStrategy aggregationStrategy,
ExecutorService executorService,
boolean shutdownExecutorService) |
Modifier and Type | Method and Description |
---|---|
void |
clearClosedCorrelationKeysCache()
Clear all the closed correlation keys stored in the cache
|
boolean |
deferShutdown(org.apache.camel.ShutdownRunningTask shutdownRunningTask) |
protected void |
doAggregationComplete(String complete,
List<org.apache.camel.Exchange> list,
String key,
org.apache.camel.Exchange originalExchange,
org.apache.camel.Exchange answer,
boolean aggregateFailed) |
protected void |
doAggregationRepositoryAdd(org.apache.camel.CamelContext camelContext,
String key,
org.apache.camel.Exchange oldExchange,
org.apache.camel.Exchange newExchange) |
protected void |
doInOptimisticLock(org.apache.camel.Exchange exchange,
String key,
org.apache.camel.AsyncCallback callback,
int attempt) |
protected void |
doProcess(org.apache.camel.Exchange exchange,
org.apache.camel.AsyncCallback callback) |
protected void |
doProcess(org.apache.camel.Exchange exchange,
String key,
org.apache.camel.AsyncCallback callback) |
protected void |
doShutdown() |
protected void |
doStart() |
protected void |
doStop() |
int |
forceCompletionOfAllGroups() |
int |
forceCompletionOfGroup(String key) |
int |
forceDiscardingOfAllGroups() |
int |
forceDiscardingOfGroup(String key) |
AggregateController |
getAggregateController() |
org.apache.camel.spi.AggregationRepository |
getAggregationRepository() |
org.apache.camel.AggregationStrategy |
getAggregationStrategy() |
protected boolean |
getAndRemoveBooleanHeader(org.apache.camel.Exchange exchange,
String key) |
protected boolean |
getAndRemoveBooleanProperty(org.apache.camel.Exchange exchange,
String key) |
protected boolean |
getBooleanProperty(org.apache.camel.Exchange exchange,
String key) |
Integer |
getCloseCorrelationKeyOnCompletion() |
int |
getClosedCorrelationKeysCacheSize()
Current number of closed correlation keys in the memory cache
|
long |
getCompletionInterval() |
org.apache.camel.Predicate |
getCompletionPredicate() |
int |
getCompletionSize() |
org.apache.camel.Expression |
getCompletionSizeExpression() |
long |
getCompletionTimeout() |
long |
getCompletionTimeoutCheckerInterval() |
org.apache.camel.Expression |
getCompletionTimeoutExpression() |
org.apache.camel.Expression |
getCorrelationExpression() |
org.apache.camel.spi.ExceptionHandler |
getExceptionHandler() |
String |
getId() |
int |
getInProgressCompleteExchanges() |
ScheduledExecutorService |
getOptimisticLockingExecutorService() |
OptimisticLockRetryPolicy |
getOptimisticLockRetryPolicy() |
int |
getPendingExchangesSize() |
AggregateProcessorStatistics |
getStatistics() |
ScheduledExecutorService |
getTimeoutCheckerExecutorService() |
String |
getTraceLabel() |
boolean |
hasNext() |
boolean |
isCompleteAllOnStop() |
protected String |
isCompleted(String key,
org.apache.camel.Exchange exchange)
Tests whether the given exchange is complete or not
|
boolean |
isCompletionFromBatchConsumer() |
boolean |
isCompletionOnNewCorrelationGroup() |
boolean |
isDiscardOnAggregationFailure() |
boolean |
isDiscardOnCompletionTimeout() |
boolean |
isEagerCheckCompletion() |
boolean |
isIgnoreInvalidCorrelationKeys() |
boolean |
isOptimisticLocking() |
boolean |
isParallelProcessing() |
protected String |
isPreCompleted(String key,
org.apache.camel.Exchange oldExchange,
org.apache.camel.Exchange newExchange)
Tests whether the given exchanges is pre-complete or not
|
boolean |
isShutdownOptimisticLockingExecutorService() |
boolean |
isShutdownTimeoutCheckerExecutorService() |
List<org.apache.camel.Processor> |
next() |
protected org.apache.camel.Exchange |
onAggregation(org.apache.camel.Exchange oldExchange,
org.apache.camel.Exchange newExchange) |
protected org.apache.camel.Exchange |
onCompletion(String key,
org.apache.camel.Exchange original,
org.apache.camel.Exchange aggregated,
boolean fromTimeout,
boolean aggregateFailed) |
protected void |
onOptimisticLockingFailure(org.apache.camel.Exchange oldExchange,
org.apache.camel.Exchange newExchange) |
void |
prepareShutdown(boolean suspendOnly,
boolean forced) |
boolean |
process(org.apache.camel.Exchange exchange,
org.apache.camel.AsyncCallback callback) |
protected void |
restoreTimeoutMapFromAggregationRepository()
Restores the timeout map with timeout values from the aggregation repository.
|
void |
setAggregateController(AggregateController aggregateController) |
void |
setAggregationRepository(org.apache.camel.spi.AggregationRepository aggregationRepository) |
void |
setAggregationStrategy(org.apache.camel.AggregationStrategy aggregationStrategy) |
void |
setCloseCorrelationKeyOnCompletion(Integer closeCorrelationKeyOnCompletion) |
void |
setCompleteAllOnStop(boolean completeAllOnStop) |
void |
setCompletionFromBatchConsumer(boolean completionFromBatchConsumer) |
void |
setCompletionInterval(long completionInterval) |
void |
setCompletionOnNewCorrelationGroup(boolean completionOnNewCorrelationGroup) |
void |
setCompletionPredicate(org.apache.camel.Predicate completionPredicate) |
void |
setCompletionSize(int completionSize) |
void |
setCompletionSizeExpression(org.apache.camel.Expression completionSizeExpression) |
void |
setCompletionTimeout(long completionTimeout) |
void |
setCompletionTimeoutCheckerInterval(long completionTimeoutCheckerInterval) |
void |
setCompletionTimeoutExpression(org.apache.camel.Expression completionTimeoutExpression) |
void |
setCorrelationExpression(org.apache.camel.Expression correlationExpression) |
void |
setDiscardOnAggregationFailure(boolean discardOnAggregationFailure) |
void |
setDiscardOnCompletionTimeout(boolean discardOnCompletionTimeout) |
void |
setEagerCheckCompletion(boolean eagerCheckCompletion) |
void |
setExceptionHandler(org.apache.camel.spi.ExceptionHandler exceptionHandler) |
void |
setForceCompletionOnStop(boolean forceCompletionOnStop) |
void |
setId(String id) |
void |
setIgnoreInvalidCorrelationKeys(boolean ignoreInvalidCorrelationKeys) |
void |
setOptimisticLocking(boolean optimisticLocking) |
void |
setOptimisticLockingExecutorService(ScheduledExecutorService optimisticLockingExecutorService) |
void |
setOptimisticLockRetryPolicy(OptimisticLockRetryPolicy optimisticLockRetryPolicy) |
void |
setParallelProcessing(boolean parallelProcessing) |
void |
setShutdownOptimisticLockingExecutorService(boolean shutdownOptimisticLockingExecutorService) |
void |
setShutdownTimeoutCheckerExecutorService(boolean shutdownTimeoutCheckerExecutorService) |
void |
setTimeoutCheckerExecutorService(ScheduledExecutorService timeoutCheckerExecutorService) |
String |
toString() |
protected void |
trackTimeout(String key,
org.apache.camel.Exchange exchange) |
doInit, doResume, doSuspend, getStatus, init, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
public static final String AGGREGATE_TIMEOUT_CHECKER
public static final String AGGREGATE_OPTIMISTIC_LOCKING_EXECUTOR
public static final String COMPLETED_BY_SIZE
public static final String COMPLETED_BY_PREDICATE
public static final String COMPLETED_BY_CONSUMER
public static final String COMPLETED_BY_STRATEGY
public static final String COMPLETED_BY_INTERVAL
public static final String COMPLETED_BY_TIMEOUT
public static final String COMPLETED_BY_FORCE
public AggregateProcessor(org.apache.camel.CamelContext camelContext, org.apache.camel.AsyncProcessor processor, org.apache.camel.Expression correlationExpression, org.apache.camel.AggregationStrategy aggregationStrategy, ExecutorService executorService, boolean shutdownExecutorService)
public String getTraceLabel()
getTraceLabel
in interface org.apache.camel.Traceable
public List<org.apache.camel.Processor> next()
next
in interface org.apache.camel.Navigate<org.apache.camel.Processor>
public boolean hasNext()
hasNext
in interface org.apache.camel.Navigate<org.apache.camel.Processor>
public String getId()
getId
in interface org.apache.camel.spi.HasId
public void setId(String id)
setId
in interface org.apache.camel.spi.IdAware
public boolean process(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback)
process
in interface org.apache.camel.AsyncProcessor
protected void doProcess(org.apache.camel.Exchange exchange, org.apache.camel.AsyncCallback callback) throws Exception
Exception
protected void doInOptimisticLock(org.apache.camel.Exchange exchange, String key, org.apache.camel.AsyncCallback callback, int attempt)
protected void doProcess(org.apache.camel.Exchange exchange, String key, org.apache.camel.AsyncCallback callback)
protected boolean getBooleanProperty(org.apache.camel.Exchange exchange, String key)
protected boolean getAndRemoveBooleanProperty(org.apache.camel.Exchange exchange, String key)
protected boolean getAndRemoveBooleanHeader(org.apache.camel.Exchange exchange, String key)
protected void doAggregationComplete(String complete, List<org.apache.camel.Exchange> list, String key, org.apache.camel.Exchange originalExchange, org.apache.camel.Exchange answer, boolean aggregateFailed)
protected void doAggregationRepositoryAdd(org.apache.camel.CamelContext camelContext, String key, org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)
protected void onOptimisticLockingFailure(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)
protected String isPreCompleted(String key, org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)
key
- the correlation keyoldExchange
- the existing exchangenewExchange
- the incoming exchangeprotected String isCompleted(String key, org.apache.camel.Exchange exchange)
key
- the correlation keyexchange
- the incoming exchangeprotected void trackTimeout(String key, org.apache.camel.Exchange exchange)
protected org.apache.camel.Exchange onAggregation(org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)
protected org.apache.camel.Exchange onCompletion(String key, org.apache.camel.Exchange original, org.apache.camel.Exchange aggregated, boolean fromTimeout, boolean aggregateFailed)
protected void restoreTimeoutMapFromAggregationRepository() throws Exception
AggregationRepository
must have their timeout conditions restored.Exception
public int getClosedCorrelationKeysCacheSize()
public void clearClosedCorrelationKeysCache()
public AggregateProcessorStatistics getStatistics()
public int getInProgressCompleteExchanges()
public org.apache.camel.Predicate getCompletionPredicate()
public void setCompletionPredicate(org.apache.camel.Predicate completionPredicate)
public boolean isEagerCheckCompletion()
public void setEagerCheckCompletion(boolean eagerCheckCompletion)
public long getCompletionTimeout()
public void setCompletionTimeout(long completionTimeout)
public org.apache.camel.Expression getCompletionTimeoutExpression()
public void setCompletionTimeoutExpression(org.apache.camel.Expression completionTimeoutExpression)
public long getCompletionInterval()
public void setCompletionInterval(long completionInterval)
public int getCompletionSize()
public void setCompletionSize(int completionSize)
public org.apache.camel.Expression getCompletionSizeExpression()
public void setCompletionSizeExpression(org.apache.camel.Expression completionSizeExpression)
public boolean isIgnoreInvalidCorrelationKeys()
public void setIgnoreInvalidCorrelationKeys(boolean ignoreInvalidCorrelationKeys)
public Integer getCloseCorrelationKeyOnCompletion()
public void setCloseCorrelationKeyOnCompletion(Integer closeCorrelationKeyOnCompletion)
public boolean isCompletionFromBatchConsumer()
public void setCompletionFromBatchConsumer(boolean completionFromBatchConsumer)
public boolean isCompletionOnNewCorrelationGroup()
public void setCompletionOnNewCorrelationGroup(boolean completionOnNewCorrelationGroup)
public boolean isCompleteAllOnStop()
public long getCompletionTimeoutCheckerInterval()
public void setCompletionTimeoutCheckerInterval(long completionTimeoutCheckerInterval)
public org.apache.camel.spi.ExceptionHandler getExceptionHandler()
public void setExceptionHandler(org.apache.camel.spi.ExceptionHandler exceptionHandler)
public boolean isParallelProcessing()
public void setParallelProcessing(boolean parallelProcessing)
public boolean isOptimisticLocking()
public void setOptimisticLocking(boolean optimisticLocking)
public org.apache.camel.spi.AggregationRepository getAggregationRepository()
public void setAggregationRepository(org.apache.camel.spi.AggregationRepository aggregationRepository)
public boolean isDiscardOnCompletionTimeout()
public void setDiscardOnCompletionTimeout(boolean discardOnCompletionTimeout)
public boolean isDiscardOnAggregationFailure()
public void setDiscardOnAggregationFailure(boolean discardOnAggregationFailure)
public void setForceCompletionOnStop(boolean forceCompletionOnStop)
public void setCompleteAllOnStop(boolean completeAllOnStop)
public void setTimeoutCheckerExecutorService(ScheduledExecutorService timeoutCheckerExecutorService)
public ScheduledExecutorService getTimeoutCheckerExecutorService()
public boolean isShutdownTimeoutCheckerExecutorService()
public void setShutdownTimeoutCheckerExecutorService(boolean shutdownTimeoutCheckerExecutorService)
public void setOptimisticLockingExecutorService(ScheduledExecutorService optimisticLockingExecutorService)
public ScheduledExecutorService getOptimisticLockingExecutorService()
public boolean isShutdownOptimisticLockingExecutorService()
public void setShutdownOptimisticLockingExecutorService(boolean shutdownOptimisticLockingExecutorService)
public void setOptimisticLockRetryPolicy(OptimisticLockRetryPolicy optimisticLockRetryPolicy)
public OptimisticLockRetryPolicy getOptimisticLockRetryPolicy()
public org.apache.camel.AggregationStrategy getAggregationStrategy()
public void setAggregationStrategy(org.apache.camel.AggregationStrategy aggregationStrategy)
public org.apache.camel.Expression getCorrelationExpression()
public void setCorrelationExpression(org.apache.camel.Expression correlationExpression)
public AggregateController getAggregateController()
public void setAggregateController(AggregateController aggregateController)
protected void doStart() throws Exception
doStart
in class org.apache.camel.support.AsyncProcessorSupport
Exception
protected void doStop() throws Exception
doStop
in class org.apache.camel.support.AsyncProcessorSupport
Exception
public void prepareShutdown(boolean suspendOnly, boolean forced)
prepareShutdown
in interface org.apache.camel.spi.ShutdownPrepared
public boolean deferShutdown(org.apache.camel.ShutdownRunningTask shutdownRunningTask)
deferShutdown
in interface org.apache.camel.spi.ShutdownAware
public int getPendingExchangesSize()
getPendingExchangesSize
in interface org.apache.camel.spi.ShutdownAware
protected void doShutdown() throws Exception
doShutdown
in class org.apache.camel.support.service.ServiceSupport
Exception
public int forceCompletionOfGroup(String key)
public int forceCompletionOfAllGroups()
public int forceDiscardingOfGroup(String key)
public int forceDiscardingOfAllGroups()
Apache Camel