Class ReplicatedHazelcastAggregationRepository
- java.lang.Object
-
- org.apache.camel.support.service.BaseService
-
- org.apache.camel.support.service.ServiceSupport
-
- org.apache.camel.processor.aggregate.hazelcast.HazelcastAggregationRepository
-
- org.apache.camel.processor.aggregate.hazelcast.ReplicatedHazelcastAggregationRepository
-
- 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
public class ReplicatedHazelcastAggregationRepository extends HazelcastAggregationRepository
A Hazelcast-based AggregationRepository implementingRecoverableAggregationRepository
andOptimisticLockingAggregationRepository
. 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 areIMap
<String, Exchange>. However ReplicatedHazelcastAggregationRepository can run it's own Hazelcast instance, but obviously no benefits of Hazelcast clustering are gained this way. If theReplicatedHazelcastAggregationRepository
uses it's own localHazelcastInstance
it will DESTROY this instance onHazelcastAggregationRepository.doStop()
. You should controlHazelcastInstance
lifecycle yourself whenever you instantiateReplicatedHazelcastAggregationRepository
passing a reference to the instance.
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,org.apache.camel.support.DefaultExchangeHolder>
replicatedCache
protected Map<String,org.apache.camel.support.DefaultExchangeHolder>
replicatedPersistedCache
-
Fields inherited from class org.apache.camel.processor.aggregate.hazelcast.HazelcastAggregationRepository
allowSerializedHeaders, cache, COMPLETED_SUFFIX, deadLetterChannel, hzInstance, mapName, maximumRedeliveries, optimistic, persistedCache, persistenceMapName, recoveryInterval, useLocalHzInstance, useRecovery
-
-
Constructor Summary
Constructors Constructor Description ReplicatedHazelcastAggregationRepository(String repositoryName)
Creates newReplicatedHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior and a local Hazelcast instance.ReplicatedHazelcastAggregationRepository(String repositoryName, boolean optimistic)
Creates newReplicatedHazelcastAggregationRepository
with recoverable behavior and a local Hazelcast instance.ReplicatedHazelcastAggregationRepository(String repositoryName, boolean optimistic, com.hazelcast.core.HazelcastInstance hzInstance)
Creates newReplicatedHazelcastAggregationRepository
with recoverable behavior.ReplicatedHazelcastAggregationRepository(String repositoryName, com.hazelcast.core.HazelcastInstance hzInstanse)
Creates newReplicatedHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior.ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName)
Creates newReplicatedHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior and a local Hazelcast instance.ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, boolean optimistic)
Creates newReplicatedHazelcastAggregationRepository
with recoverable behavior and a local Hazelcast instance.ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, boolean optimistic, com.hazelcast.core.HazelcastInstance hzInstance)
Creates newReplicatedHazelcastAggregationRepository
with recoverable behavior.ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, com.hazelcast.core.HazelcastInstance hzInstanse)
Creates newReplicatedHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.camel.Exchange
add(org.apache.camel.CamelContext camelContext, String key, org.apache.camel.Exchange exchange)
org.apache.camel.Exchange
add(org.apache.camel.CamelContext camelContext, String key, org.apache.camel.Exchange oldExchange, org.apache.camel.Exchange newExchange)
void
confirm(org.apache.camel.CamelContext camelContext, String exchangeId)
boolean
containsKey(Object key)
Checks if the key in question is in the repository.protected void
doStart()
org.apache.camel.Exchange
get(org.apache.camel.CamelContext camelContext, String key)
Set<String>
getKeys()
org.apache.camel.Exchange
recover(org.apache.camel.CamelContext camelContext, String exchangeId)
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.Set<String>
scan(org.apache.camel.CamelContext camelContext)
-
Methods inherited from class org.apache.camel.processor.aggregate.hazelcast.HazelcastAggregationRepository
doStop, getDeadLetterUri, getMaximumRedeliveries, getPersistentRepositoryName, getRecoveryIntervalInMillis, isAllowSerializedHeaders, isUseRecovery, setAllowSerializedHeaders, setDeadLetterUri, setMaximumRedeliveries, setRecoveryInterval, setRecoveryInterval, setUseRecovery, unmarshallExchange
-
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
-
-
-
-
Constructor Detail
-
ReplicatedHazelcastAggregationRepository
public ReplicatedHazelcastAggregationRepository(String repositoryName)
Creates newReplicatedHazelcastAggregationRepository
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;
-
ReplicatedHazelcastAggregationRepository
public ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName)
Creates newReplicatedHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior and a local Hazelcast instance.- Parameters:
repositoryName
-IMap
repository name;persistentRepositoryName
-IMap
recoverable repository name;
-
ReplicatedHazelcastAggregationRepository
public ReplicatedHazelcastAggregationRepository(String repositoryName, boolean optimistic)
Creates newReplicatedHazelcastAggregationRepository
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.
-
ReplicatedHazelcastAggregationRepository
public ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, boolean optimistic)
Creates newReplicatedHazelcastAggregationRepository
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.
-
ReplicatedHazelcastAggregationRepository
public ReplicatedHazelcastAggregationRepository(String repositoryName, com.hazelcast.core.HazelcastInstance hzInstanse)
Creates newReplicatedHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior. Recoverable repository name defaults torepositoryName
+ "-compeleted".- Parameters:
repositoryName
-IMap
repository name;hzInstanse
- externally configuredHazelcastInstance
.
-
ReplicatedHazelcastAggregationRepository
public ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, com.hazelcast.core.HazelcastInstance hzInstanse)
Creates newReplicatedHazelcastAggregationRepository
that defaults to non-optimistic locking with recoverable behavior.- Parameters:
repositoryName
-IMap
repository name;persistentRepositoryName
-IMap
recoverable repository name;hzInstanse
- externally configuredHazelcastInstance
.
-
ReplicatedHazelcastAggregationRepository
public ReplicatedHazelcastAggregationRepository(String repositoryName, boolean optimistic, com.hazelcast.core.HazelcastInstance hzInstance)
Creates newReplicatedHazelcastAggregationRepository
with recoverable behavior. Recoverable repository name defaults torepositoryName
+ "-compeleted".- Parameters:
repositoryName
-IMap
repository name;optimistic
- whether to use optimistic locking manner;hzInstance
- externally configuredHazelcastInstance
.
-
ReplicatedHazelcastAggregationRepository
public ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, boolean optimistic, com.hazelcast.core.HazelcastInstance hzInstance)
Creates newReplicatedHazelcastAggregationRepository
with recoverable behavior.- Parameters:
repositoryName
-IMap
repository name;optimistic
- whether to use optimistic locking manner;persistentRepositoryName
-IMap
recoverable repository name;hzInstance
- externally configuredHazelcastInstance
.
-
-
Method Detail
-
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
- Overrides:
add
in classHazelcastAggregationRepository
- 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
- Overrides:
add
in classHazelcastAggregationRepository
-
scan
public Set<String> scan(org.apache.camel.CamelContext camelContext)
- Specified by:
scan
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
- Overrides:
scan
in classHazelcastAggregationRepository
-
recover
public org.apache.camel.Exchange recover(org.apache.camel.CamelContext camelContext, String exchangeId)
- Specified by:
recover
in interfaceorg.apache.camel.spi.RecoverableAggregationRepository
- Overrides:
recover
in classHazelcastAggregationRepository
-
get
public org.apache.camel.Exchange get(org.apache.camel.CamelContext camelContext, String key)
- Specified by:
get
in interfaceorg.apache.camel.spi.AggregationRepository
- Overrides:
get
in classHazelcastAggregationRepository
-
containsKey
public boolean containsKey(Object key)
Checks if the key in question is in the repository.- Overrides:
containsKey
in classHazelcastAggregationRepository
- Parameters:
key
- Object - key in question
-
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
- Overrides:
remove
in classHazelcastAggregationRepository
- Parameters:
camelContext
- the current CamelContextkey
- the correlation keyexchange
- the exchange to remove
-
confirm
public void confirm(org.apache.camel.CamelContext camelContext, String exchangeId)
- Specified by:
confirm
in interfaceorg.apache.camel.spi.AggregationRepository
- Overrides:
confirm
in classHazelcastAggregationRepository
-
getKeys
public Set<String> getKeys()
- Specified by:
getKeys
in interfaceorg.apache.camel.spi.AggregationRepository
- Overrides:
getKeys
in classHazelcastAggregationRepository
-
doStart
protected void doStart() throws Exception
- Overrides:
doStart
in classHazelcastAggregationRepository
- Throws:
Exception
-
-