|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.camel.support.ServiceSupport org.apache.camel.processor.aggregate.AggregateProcessor
public class AggregateProcessor
An implementation of the Aggregator
pattern where a batch of messages are processed (up to a maximum amount or
until some timeout is reached) and messages for the same correlation key are
combined together using some kind of AggregationStrategy
(by default the latest message is used) to compress many message exchanges
into a smaller number of exchanges.
Field Summary | |
---|---|
static String |
AGGREGATE_TIMEOUT_CHECKER
|
Fields inherited from class org.apache.camel.support.ServiceSupport |
---|
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending |
Constructor Summary | |
---|---|
AggregateProcessor(CamelContext camelContext,
Processor processor,
Expression correlationExpression,
AggregationStrategy aggregationStrategy,
ExecutorService executorService,
boolean shutdownExecutorService)
|
Method Summary | |
---|---|
protected void |
doAggregationRepositoryAdd(CamelContext camelContext,
String key,
Exchange oldExchange,
Exchange newExchange)
|
protected void |
doProcess(Exchange exchange)
|
protected void |
doShutdown()
Implementations override this method to perform customized shutdown. |
protected void |
doStart()
Implementations override this method to support customized start/stop. |
protected void |
doStop()
Implementations override this method to support customized start/stop. |
int |
forceCompletionOfAllGroups()
|
AggregationRepository |
getAggregationRepository()
|
AggregationStrategy |
getAggregationStrategy()
|
Integer |
getCloseCorrelationKeyOnCompletion()
|
long |
getCompletionInterval()
|
Predicate |
getCompletionPredicate()
|
int |
getCompletionSize()
|
Expression |
getCompletionSizeExpression()
|
long |
getCompletionTimeout()
|
Expression |
getCompletionTimeoutExpression()
|
Expression |
getCorrelationExpression()
|
ExceptionHandler |
getExceptionHandler()
|
OptimisticLockRetryPolicy |
getOptimisticLockRetryPolicy()
|
ScheduledExecutorService |
getTimeoutCheckerExecutorService()
|
String |
getTraceLabel()
Gets the trace label used for logging when tracing is enabled. |
boolean |
hasNext()
Are there more outputs? |
protected String |
isCompleted(String key,
Exchange exchange)
Tests whether the given exchange is complete or not |
boolean |
isCompletionFromBatchConsumer()
|
boolean |
isDiscardOnCompletionTimeout()
|
boolean |
isEagerCheckCompletion()
|
boolean |
isIgnoreInvalidCorrelationKeys()
|
boolean |
isOptimisticLocking()
|
boolean |
isParallelProcessing()
|
boolean |
isShutdownTimeoutCheckerExecutorService()
|
List<Processor> |
next()
Next group of outputs |
protected Exchange |
onAggregation(Exchange oldExchange,
Exchange newExchange)
|
protected void |
onCompletion(String key,
Exchange original,
Exchange aggregated,
boolean fromTimeout)
|
protected void |
onOptimisticLockingFailure(Exchange oldExchange,
Exchange newExchange)
|
void |
prepareShutdown(boolean forced)
Prepares for shutdown. |
void |
process(Exchange exchange)
Processes the message exchange |
boolean |
process(Exchange exchange,
AsyncCallback callback)
Processes the message exchange. |
protected void |
restoreTimeoutMapFromAggregationRepository()
Restores the timeout map with timeout values from the aggregation repository. |
void |
setAggregationRepository(AggregationRepository aggregationRepository)
|
void |
setAggregationStrategy(AggregationStrategy aggregationStrategy)
|
void |
setCloseCorrelationKeyOnCompletion(Integer closeCorrelationKeyOnCompletion)
|
void |
setCompletionFromBatchConsumer(boolean completionFromBatchConsumer)
|
void |
setCompletionInterval(long completionInterval)
|
void |
setCompletionPredicate(Predicate completionPredicate)
|
void |
setCompletionSize(int completionSize)
|
void |
setCompletionSizeExpression(Expression completionSizeExpression)
|
void |
setCompletionTimeout(long completionTimeout)
|
void |
setCompletionTimeoutExpression(Expression completionTimeoutExpression)
|
void |
setCorrelationExpression(Expression correlationExpression)
|
void |
setDiscardOnCompletionTimeout(boolean discardOnCompletionTimeout)
|
void |
setEagerCheckCompletion(boolean eagerCheckCompletion)
|
void |
setExceptionHandler(ExceptionHandler exceptionHandler)
|
void |
setForceCompletionOnStop(boolean forceCompletionOnStop)
|
void |
setIgnoreInvalidCorrelationKeys(boolean ignoreInvalidCorrelationKeys)
|
void |
setOptimisticLocking(boolean optimisticLocking)
|
void |
setOptimisticLockRetryPolicy(OptimisticLockRetryPolicy optimisticLockRetryPolicy)
|
void |
setParallelProcessing(boolean parallelProcessing)
|
void |
setShutdownTimeoutCheckerExecutorService(boolean shutdownTimeoutCheckerExecutorService)
|
void |
setTimeoutCheckerExecutorService(ScheduledExecutorService timeoutCheckerExecutorService)
|
String |
toString()
|
Methods inherited from class org.apache.camel.support.ServiceSupport |
---|
doResume, doSuspend, getStatus, getVersion, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, resume, shutdown, start, stop, suspend |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String AGGREGATE_TIMEOUT_CHECKER
Constructor Detail |
---|
public AggregateProcessor(CamelContext camelContext, Processor processor, Expression correlationExpression, AggregationStrategy aggregationStrategy, ExecutorService executorService, boolean shutdownExecutorService)
Method Detail |
---|
public String toString()
toString
in class Object
public String getTraceLabel()
Traceable
getTraceLabel
in interface Traceable
public List<Processor> next()
Navigate
next
in interface Navigate<Processor>
public boolean hasNext()
Navigate
hasNext
in interface Navigate<Processor>
public void process(Exchange exchange) throws Exception
Processor
process
in interface Processor
exchange
- the message exchange
Exception
- if an internal processing error has occurred.public boolean process(Exchange exchange, AsyncCallback callback)
AsyncProcessor
Processor.process(org.apache.camel.Exchange)
, but the caller supports having the exchange asynchronously processed.
If there was a failure processing then the caused Exception
would be set on the Exchange
.
process
in interface AsyncProcessor
exchange
- the message exchangecallback
- the AsyncCallback
will be invoked when the processing of the exchange is completed.
If the exchange is completed synchronously, then the callback is also invoked synchronously.
The callback should therefore be careful of starting recursive loop.
protected void doProcess(Exchange exchange) throws Exception
Exception
protected void doAggregationRepositoryAdd(CamelContext camelContext, String key, Exchange oldExchange, Exchange newExchange)
protected void onOptimisticLockingFailure(Exchange oldExchange, Exchange newExchange)
protected String isCompleted(String key, Exchange exchange)
key
- the correlation keyexchange
- the incoming exchange
protected Exchange onAggregation(Exchange oldExchange, Exchange newExchange)
protected void onCompletion(String key, Exchange original, Exchange aggregated, boolean fromTimeout)
protected void restoreTimeoutMapFromAggregationRepository() throws Exception
AggregationRepository
must have their timeout conditions restored.
Exception
public Predicate getCompletionPredicate()
public void setCompletionPredicate(Predicate completionPredicate)
public boolean isEagerCheckCompletion()
public void setEagerCheckCompletion(boolean eagerCheckCompletion)
public long getCompletionTimeout()
public void setCompletionTimeout(long completionTimeout)
public Expression getCompletionTimeoutExpression()
public void setCompletionTimeoutExpression(Expression completionTimeoutExpression)
public long getCompletionInterval()
public void setCompletionInterval(long completionInterval)
public int getCompletionSize()
public void setCompletionSize(int completionSize)
public Expression getCompletionSizeExpression()
public void setCompletionSizeExpression(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 ExceptionHandler getExceptionHandler()
public void setExceptionHandler(ExceptionHandler exceptionHandler)
public boolean isParallelProcessing()
public void setParallelProcessing(boolean parallelProcessing)
public boolean isOptimisticLocking()
public void setOptimisticLocking(boolean optimisticLocking)
public AggregationRepository getAggregationRepository()
public void setAggregationRepository(AggregationRepository aggregationRepository)
public boolean isDiscardOnCompletionTimeout()
public void setDiscardOnCompletionTimeout(boolean discardOnCompletionTimeout)
public void setForceCompletionOnStop(boolean forceCompletionOnStop)
public void setTimeoutCheckerExecutorService(ScheduledExecutorService timeoutCheckerExecutorService)
public ScheduledExecutorService getTimeoutCheckerExecutorService()
public boolean isShutdownTimeoutCheckerExecutorService()
public void setShutdownTimeoutCheckerExecutorService(boolean shutdownTimeoutCheckerExecutorService)
public void setOptimisticLockRetryPolicy(OptimisticLockRetryPolicy optimisticLockRetryPolicy)
public OptimisticLockRetryPolicy getOptimisticLockRetryPolicy()
public AggregationStrategy getAggregationStrategy()
public void setAggregationStrategy(AggregationStrategy aggregationStrategy)
public Expression getCorrelationExpression()
public void setCorrelationExpression(Expression correlationExpression)
protected void doStart() throws Exception
ServiceSupport
ServiceSupport.doStop()
for more details.
doStart
in class ServiceSupport
Exception
ServiceSupport.doStop()
protected void doStop() throws Exception
ServiceSupport
ServiceSupport.doStop()
method when
the service is being stopped. This method will also be invoked
if the service is still in uninitialized state (eg has not
been started). The method is always called to allow the service
to do custom logic when the service is being stopped, such as when
CamelContext
is shutting down.
doStop
in class ServiceSupport
Exception
ServiceSupport.doStart()
public void prepareShutdown(boolean forced)
ShutdownPrepared
ShutdownStrategy
supports preparing for shutdown using two steps.
First a regular preparation, where the given forced parameter will be false.
And if the shutdown times out, then the ShutdownStrategy
performs a more aggressive
shutdown, calling this method a second time with true for the given forced parameter.
For example by graceful stopping any threads or the likes.
For forced shutdown, then the service is expected to aggressively shutdown any child services, such
as thread pools etc. This is the last chance it has to perform such duties.
prepareShutdown
in interface ShutdownPrepared
forced
- true is forcing a more aggressive shutdown, false is for preparing to shutdown.protected void doShutdown() throws Exception
ServiceSupport
doShutdown
in class ServiceSupport
Exception
public int forceCompletionOfAllGroups()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |