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 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 ReplicatedHazelcastAggregationRepository can run it's own Hazelcast instance, but obviously no benefits of Hazelcast clustering are gained this way. If the ReplicatedHazelcastAggregationRepository uses it's own local HazelcastInstance it will DESTROY this instance on HazelcastAggregationRepository.doStop(). You should control HazelcastInstance lifecycle yourself whenever you instantiate ReplicatedHazelcastAggregationRepository passing a reference to the instance.
  • Field Details

    • replicatedCache

      protected Map<String,org.apache.camel.support.DefaultExchangeHolder> replicatedCache
    • replicatedPersistedCache

      protected Map<String,org.apache.camel.support.DefaultExchangeHolder> replicatedPersistedCache
  • Constructor Details

    • ReplicatedHazelcastAggregationRepository

      public ReplicatedHazelcastAggregationRepository(String repositoryName)
      Creates new ReplicatedHazelcastAggregationRepository that defaults to non-optimistic locking with recoverable behavior and a local Hazelcast instance. Recoverable repository name defaults to repositoryName + "-compeleted".
      Parameters:
      repositoryName - IMap repository name;
    • ReplicatedHazelcastAggregationRepository

      public ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName)
      Creates new ReplicatedHazelcastAggregationRepository 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 new ReplicatedHazelcastAggregationRepository with recoverable behavior and a local Hazelcast instance. Recoverable repository name defaults to repositoryName + "-compeleted".
      Parameters:
      repositoryName - IMap repository name;
      optimistic - whether to use optimistic locking manner.
    • ReplicatedHazelcastAggregationRepository

      public ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, boolean optimistic)
      Creates new ReplicatedHazelcastAggregationRepository 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 new ReplicatedHazelcastAggregationRepository that defaults to non-optimistic locking with recoverable behavior. Recoverable repository name defaults to repositoryName + "-compeleted".
      Parameters:
      repositoryName - IMap repository name;
      hzInstanse - externally configured HazelcastInstance.
    • ReplicatedHazelcastAggregationRepository

      public ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, com.hazelcast.core.HazelcastInstance hzInstanse)
      Creates new ReplicatedHazelcastAggregationRepository that defaults to non-optimistic locking with recoverable behavior.
      Parameters:
      repositoryName - IMap repository name;
      persistentRepositoryName - IMap recoverable repository name;
      hzInstanse - externally configured HazelcastInstance.
    • ReplicatedHazelcastAggregationRepository

      public ReplicatedHazelcastAggregationRepository(String repositoryName, boolean optimistic, com.hazelcast.core.HazelcastInstance hzInstance)
      Creates new ReplicatedHazelcastAggregationRepository with recoverable behavior. Recoverable repository name defaults to repositoryName + "-compeleted".
      Parameters:
      repositoryName - IMap repository name;
      optimistic - whether to use optimistic locking manner;
      hzInstance - externally configured HazelcastInstance.
    • ReplicatedHazelcastAggregationRepository

      public ReplicatedHazelcastAggregationRepository(String repositoryName, String persistentRepositoryName, boolean optimistic, com.hazelcast.core.HazelcastInstance hzInstance)
      Creates new ReplicatedHazelcastAggregationRepository with recoverable behavior.
      Parameters:
      repositoryName - IMap repository name;
      optimistic - whether to use optimistic locking manner;
      persistentRepositoryName - IMap recoverable repository name;
      hzInstance - externally configured HazelcastInstance.
  • 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 interface org.apache.camel.spi.OptimisticLockingAggregationRepository
      Overrides:
      add in class HazelcastAggregationRepository
      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 interface org.apache.camel.spi.AggregationRepository
      Overrides:
      add in class HazelcastAggregationRepository
    • scan

      public Set<String> scan(org.apache.camel.CamelContext camelContext)
      Specified by:
      scan in interface org.apache.camel.spi.RecoverableAggregationRepository
      Overrides:
      scan in class HazelcastAggregationRepository
    • recover

      public org.apache.camel.Exchange recover(org.apache.camel.CamelContext camelContext, String exchangeId)
      Specified by:
      recover in interface org.apache.camel.spi.RecoverableAggregationRepository
      Overrides:
      recover in class HazelcastAggregationRepository
    • get

      public org.apache.camel.Exchange get(org.apache.camel.CamelContext camelContext, String key)
      Specified by:
      get in interface org.apache.camel.spi.AggregationRepository
      Overrides:
      get in class HazelcastAggregationRepository
    • containsKey

      public boolean containsKey(Object key)
      Checks if the key in question is in the repository.
      Overrides:
      containsKey in class HazelcastAggregationRepository
      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 the exchange from the operational storage and moving it into the persistent one if the HazelcastAggregationRepository runs in recoverable mode and optimistic is false. It will act at your own risk otherwise.
      Specified by:
      remove in interface org.apache.camel.spi.AggregationRepository
      Specified by:
      remove in interface org.apache.camel.spi.OptimisticLockingAggregationRepository
      Overrides:
      remove in class HazelcastAggregationRepository
      Parameters:
      camelContext - the current CamelContext
      key - the correlation key
      exchange - the exchange to remove
    • confirm

      public void confirm(org.apache.camel.CamelContext camelContext, String exchangeId)
      Specified by:
      confirm in interface org.apache.camel.spi.AggregationRepository
      Overrides:
      confirm in class HazelcastAggregationRepository
    • getKeys

      public Set<String> getKeys()
      Specified by:
      getKeys in interface org.apache.camel.spi.AggregationRepository
      Overrides:
      getKeys in class HazelcastAggregationRepository
    • doStart

      protected void doStart() throws Exception
      Overrides:
      doStart in class HazelcastAggregationRepository
      Throws:
      Exception