|
||||||||||
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.MemoryAggregationRepository
public class MemoryAggregationRepository
A memory based AggregationRepository
which stores Exchange
s in memory only.
Supports both optimistic locking and non-optimistic locking modes. Defaults to non-optimistic locking mode.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.apache.camel.spi.OptimisticLockingAggregationRepository |
---|
OptimisticLockingAggregationRepository.OptimisticLockingException |
Field Summary |
---|
Fields inherited from class org.apache.camel.support.ServiceSupport |
---|
shutdown, shuttingdown, started, starting, stopped, stopping, suspended, suspending |
Constructor Summary | |
---|---|
MemoryAggregationRepository()
|
|
MemoryAggregationRepository(boolean optimisticLocking)
|
Method Summary | |
---|---|
Exchange |
add(CamelContext camelContext,
String key,
Exchange exchange)
Add the given Exchange under the correlation key. |
Exchange |
add(CamelContext camelContext,
String key,
Exchange oldExchange,
Exchange newExchange)
Add the given Exchange under the correlation key. |
void |
confirm(CamelContext camelContext,
String exchangeId)
Confirms the completion of the Exchange . |
protected void |
doStart()
Implementations override this method to support customized start/stop. |
protected void |
doStop()
Implementations override this method to support customized start/stop. |
Exchange |
get(CamelContext camelContext,
String key)
Gets the given exchange with the correlation key This method is always invoked for any incoming exchange in the aggregator. |
Set<String> |
getKeys()
Gets the keys currently in the repository. |
void |
remove(CamelContext camelContext,
String key,
Exchange exchange)
Removes the given Exchange when both the supplied key and Exchange are present in the repository. |
Methods inherited from class org.apache.camel.support.ServiceSupport |
---|
doResume, doShutdown, 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, toString, wait, wait, wait |
Constructor Detail |
---|
public MemoryAggregationRepository()
public MemoryAggregationRepository(boolean optimisticLocking)
Method Detail |
---|
public Exchange add(CamelContext camelContext, String key, Exchange oldExchange, Exchange newExchange)
OptimisticLockingAggregationRepository
Exchange
under the correlation key.
Will perform optimistic locking to replace expected existing exchange with the new supplied exchange.
If the oldExchange
is null the underlying implementation is to assume this is the very first Exchange for the
supplied correlation key. When the implementation comes to store to the Exchange if there is already an existing
Exchange present for this correlation key the implementation should throw an OptimisticLockingException.
If the oldExchange
is not null the underlying implementation should use it to compare with the existing exchange
when doing an atomic compare-and-set/swap operation.
The implementation may achieve this by storing a version identifier in the Exchange as a parameter. Set before
returning from AggregationRepository.get(org.apache.camel.CamelContext, String)
} and retrieved from the
exchange when passed to AggregationRepository.add(org.apache.camel.CamelContext, String, org.apache.camel.Exchange)
.
Note: The MemoryAggregationRepository
is an exception to this recommendation.
It uses the oldExchange
's Object identify to perform it's compare-and-set/swap operation, instead of a version
parameter. This is not the recommended approach, and should be avoided.
The AggregateProcessor
will ensure that the exchange received from
AggregationRepository.get(org.apache.camel.CamelContext, String)
is passed as oldExchange
,
and that the aggregated exchange received from the AggregationStrategy
is passed as the newExchange
.
add
in interface OptimisticLockingAggregationRepository
camelContext
- the current CamelContextkey
- the correlation keyoldExchange
- the old exchange that is expected to exist when replacing with the new exchangenewExchange
- the new aggregated exchange, to replace old exchange
public Exchange add(CamelContext camelContext, String key, Exchange exchange)
AggregationRepository
Exchange
under the correlation key.
Will replace any existing exchange.
Important: This method is not invoked if only one exchange was completed, and therefore
the exchange does not need to be added to a repository, as its completed immediately.
add
in interface AggregationRepository
camelContext
- the current CamelContextkey
- the correlation keyexchange
- the aggregated exchange
public Exchange get(CamelContext camelContext, String key)
AggregationRepository
get
in interface AggregationRepository
camelContext
- the current CamelContextkey
- the correlation key
public void remove(CamelContext camelContext, String key, Exchange exchange)
OptimisticLockingAggregationRepository
remove
in interface AggregationRepository
remove
in interface OptimisticLockingAggregationRepository
camelContext
- the current CamelContextkey
- the correlation keyexchange
- the exchange to removepublic void confirm(CamelContext camelContext, String exchangeId)
AggregationRepository
Exchange
.
This method is always invoked.
confirm
in interface AggregationRepository
camelContext
- the current CamelContextexchangeId
- exchange id to confirmpublic Set<String> getKeys()
AggregationRepository
getKeys
in interface AggregationRepository
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()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |