Class HazelcastAggregationRepository
java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.processor.aggregate.hazelcast.HazelcastAggregationRepository
- All Implemented Interfaces:
AutoCloseable
,org.apache.camel.Service
,org.apache.camel.ShutdownableService
,org.apache.camel.spi.AggregationRepository
,org.apache.camel.spi.OptimisticLockingAggregationRepository
,org.apache.camel.spi.RecoverableAggregationRepository
,org.apache.camel.StatefulService
,org.apache.camel.SuspendableService
- Direct Known Subclasses:
ReplicatedHazelcastAggregationRepository
public class HazelcastAggregationRepository
extends org.apache.camel.support.service.ServiceSupport
implements org.apache.camel.spi.RecoverableAggregationRepository, org.apache.camel.spi.OptimisticLockingAggregationRepository
A Hazelcast-based AggregationRepository implementing
RecoverableAggregationRepository
and
OptimisticLockingAggregationRepository
. Defaults to thread-safe (non-optimistic) locking and recoverable
strategy. Hazelcast settings are given to an end-user and can be controlled with repositoryName and
persistentRespositoryName, both are IMap
<String, Exchange>. However
HazelcastAggregationRepository can run it's own Hazelcast instance, but obviously no benefits of Hazelcast clustering
are gained this way. If the HazelcastAggregationRepository
uses it's own local HazelcastInstance
it
will DESTROY this instance on doStop()
. You should control HazelcastInstance
lifecycle yourself
whenever you instantiate HazelcastAggregationRepository
passing a reference to the instance.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.camel.spi.OptimisticLockingAggregationRepository
org.apache.camel.spi.OptimisticLockingAggregationRepository.OptimisticLockingException
-
Field Summary
Modifier and TypeFieldDescriptionprotected boolean
protected com.hazelcast.map.IMap<String,
org.apache.camel.support.DefaultExchangeHolder> protected static final String
protected String
protected com.hazelcast.core.HazelcastInstance
protected String
protected int
protected boolean
protected com.hazelcast.map.IMap<String,
org.apache.camel.support.DefaultExchangeHolder> protected String
protected long
protected boolean
protected boolean
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
ConstructorDescriptionHazelcastAggregationRepository
(String repositoryName) Creates newHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior and a local Hazelcast instance.HazelcastAggregationRepository
(String repositoryName, boolean optimistic) Creates newHazelcastAggregationRepository
with recoverable behavior and a local Hazelcast instance.HazelcastAggregationRepository
(String repositoryName, boolean optimistic, com.hazelcast.core.HazelcastInstance hzInstance) Creates newHazelcastAggregationRepository
with recoverable behavior.HazelcastAggregationRepository
(String repositoryName, com.hazelcast.core.HazelcastInstance hzInstanse) Creates newHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior.HazelcastAggregationRepository
(String repositoryName, String persistentRepositoryName) Creates newHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior and a local Hazelcast instance.HazelcastAggregationRepository
(String repositoryName, String persistentRepositoryName, boolean optimistic) Creates newHazelcastAggregationRepository
with recoverable behavior and a local Hazelcast instance.HazelcastAggregationRepository
(String repositoryName, String persistentRepositoryName, boolean optimistic, com.hazelcast.core.HazelcastInstance hzInstance) Creates newHazelcastAggregationRepository
with recoverable behavior.HazelcastAggregationRepository
(String repositoryName, String persistentRepositoryName, com.hazelcast.core.HazelcastInstance hzInstanse) Creates newHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.camel.Exchange
org.apache.camel.Exchange
add
(org.apache.camel.CamelContext camelContext, String key, org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange) void
boolean
containsKey
(Object key) Checks if the key in question is in the repository.protected void
doStart()
protected void
doStop()
org.apache.camel.Exchange
getKeys()
int
long
boolean
boolean
org.apache.camel.Exchange
void
This method performs transactional operation on removing theexchange
from the operational storage and moving it into the persistent one if theHazelcastAggregationRepository
runs in recoverable mode andoptimistic
is false.scan
(org.apache.camel.CamelContext camelContext) void
setAllowSerializedHeaders
(boolean allowSerializedHeaders) void
setDeadLetterUri
(String deadLetterUri) void
setMaximumRedeliveries
(int maximumRedeliveries) void
setRecoveryInterval
(long interval) void
setRecoveryInterval
(long interval, TimeUnit timeUnit) void
setUseRecovery
(boolean useRecovery) protected org.apache.camel.Exchange
unmarshallExchange
(org.apache.camel.CamelContext camelContext, org.apache.camel.support.DefaultExchangeHolder holder) Methods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doInit, 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, toString, wait, wait, wait
Methods inherited from interface org.apache.camel.spi.RecoverableAggregationRepository
confirmWithResult
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
-
COMPLETED_SUFFIX
- See Also:
-
optimistic
protected boolean optimistic -
useLocalHzInstance
protected boolean useLocalHzInstance -
useRecovery
protected boolean useRecovery -
cache
-
persistedCache
protected com.hazelcast.map.IMap<String,org.apache.camel.support.DefaultExchangeHolder> persistedCache -
hzInstance
protected com.hazelcast.core.HazelcastInstance hzInstance -
mapName
-
persistenceMapName
-
deadLetterChannel
-
recoveryInterval
protected long recoveryInterval -
maximumRedeliveries
protected int maximumRedeliveries -
allowSerializedHeaders
protected boolean allowSerializedHeaders
-
-
Constructor Details
-
HazelcastAggregationRepository
Creates newHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior and a local Hazelcast instance. Recoverable repository name defaults torepositoryName
+ "-compeleted".- Parameters:
repositoryName
-IMap
repository name;
-
HazelcastAggregationRepository
Creates newHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior and a local Hazelcast instance.- Parameters:
repositoryName
-IMap
repository name;persistentRepositoryName
-IMap
recoverable repository name;
-
HazelcastAggregationRepository
Creates newHazelcastAggregationRepository
with recoverable behavior and a local Hazelcast instance. Recoverable repository name defaults torepositoryName
+ "-compeleted".- Parameters:
repositoryName
-IMap
repository name;optimistic
- whether to use optimistic locking manner.
-
HazelcastAggregationRepository
public HazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, boolean optimistic) Creates newHazelcastAggregationRepository
with recoverable behavior and a local Hazelcast instance.- Parameters:
repositoryName
-IMap
repository name;persistentRepositoryName
-IMap
recoverable repository name;optimistic
- whether to use optimistic locking manner.
-
HazelcastAggregationRepository
public HazelcastAggregationRepository(String repositoryName, com.hazelcast.core.HazelcastInstance hzInstanse) Creates newHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior. Recoverable repository name defaults torepositoryName
+ "-compeleted".- Parameters:
repositoryName
-IMap
repository name;hzInstanse
- externally configuredHazelcastInstance
.
-
HazelcastAggregationRepository
public HazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, com.hazelcast.core.HazelcastInstance hzInstanse) Creates newHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior.- Parameters:
repositoryName
-IMap
repository name;persistentRepositoryName
-IMap
recoverable repository name;hzInstanse
- externally configuredHazelcastInstance
.
-
HazelcastAggregationRepository
public HazelcastAggregationRepository(String repositoryName, boolean optimistic, com.hazelcast.core.HazelcastInstance hzInstance) Creates newHazelcastAggregationRepository
with recoverable behavior. Recoverable repository name defaults torepositoryName
+ "-compeleted".- Parameters:
repositoryName
-IMap
repository name;optimistic
- whether to use optimistic locking manner;hzInstance
- externally configuredHazelcastInstance
.
-
HazelcastAggregationRepository
public HazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, boolean optimistic, com.hazelcast.core.HazelcastInstance hzInstance) Creates newHazelcastAggregationRepository
with recoverable behavior.- Parameters:
repositoryName
-IMap
repository name;optimistic
- whether to use optimistic locking manner;persistentRepositoryName
-IMap
recoverable repository name;hzInstance
- externally configuredHazelcastInstance
.
-
-
Method Details
-
add
public org.apache.camel.Exchange add(org.apache.camel.CamelContext camelContext, String key, org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange) throws org.apache.camel.spi.OptimisticLockingAggregationRepository.OptimisticLockingException - Specified by:
add
in interfaceorg.apache.camel.spi.OptimisticLockingAggregationRepository
- Throws:
org.apache.camel.spi.OptimisticLockingAggregationRepository.OptimisticLockingException
-
add
public org.apache.camel.Exchange add(org.apache.camel.CamelContext camelContext, String key, org.apache.camel.Exchange exchange) - Specified by:
add
in interfaceorg.apache.camel.spi.AggregationRepository
-
scan
- Specified by:
scan
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
-
recover
public org.apache.camel.Exchange recover(org.apache.camel.CamelContext camelContext, String exchangeId) - Specified by:
recover
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
-
setRecoveryInterval
- Specified by:
setRecoveryInterval
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
-
setRecoveryInterval
public void setRecoveryInterval(long interval) - Specified by:
setRecoveryInterval
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
-
getRecoveryIntervalInMillis
public long getRecoveryIntervalInMillis()- Specified by:
getRecoveryIntervalInMillis
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
-
setUseRecovery
public void setUseRecovery(boolean useRecovery) - Specified by:
setUseRecovery
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
-
isUseRecovery
public boolean isUseRecovery()- Specified by:
isUseRecovery
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
-
setDeadLetterUri
- Specified by:
setDeadLetterUri
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
-
getDeadLetterUri
- Specified by:
getDeadLetterUri
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
-
setMaximumRedeliveries
public void setMaximumRedeliveries(int maximumRedeliveries) - Specified by:
setMaximumRedeliveries
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
-
getMaximumRedeliveries
public int getMaximumRedeliveries()- Specified by:
getMaximumRedeliveries
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
-
get
- Specified by:
get
in interfaceorg.apache.camel.spi.AggregationRepository
-
containsKey
Checks if the key in question is in the repository.- Parameters:
key
- Object - key in question
-
isAllowSerializedHeaders
public boolean isAllowSerializedHeaders() -
setAllowSerializedHeaders
public void setAllowSerializedHeaders(boolean allowSerializedHeaders) -
remove
public void remove(org.apache.camel.CamelContext camelContext, String key, org.apache.camel.Exchange exchange) This method performs transactional operation on removing theexchange
from the operational storage and moving it into the persistent one if theHazelcastAggregationRepository
runs in recoverable mode andoptimistic
is false. It will act at your own risk otherwise.- Specified by:
remove
in interfaceorg.apache.camel.spi.AggregationRepository
- Specified by:
remove
in interfaceorg.apache.camel.spi.OptimisticLockingAggregationRepository
- Parameters:
camelContext
- the current CamelContextkey
- the correlation keyexchange
- the exchange to remove
-
confirm
- Specified by:
confirm
in interfaceorg.apache.camel.spi.AggregationRepository
-
getKeys
- Specified by:
getKeys
in interfaceorg.apache.camel.spi.AggregationRepository
-
getPersistentRepositoryName
- Returns:
- Persistent repository
IMap
name;
-
doStart
- Overrides:
doStart
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
doStop
- Overrides:
doStop
in classorg.apache.camel.support.service.BaseService
- Throws:
Exception
-
unmarshallExchange
protected org.apache.camel.Exchange unmarshallExchange(org.apache.camel.CamelContext camelContext, org.apache.camel.support.DefaultExchangeHolder holder)
-