Class CassandraAggregationRepository

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.AggregationRepository, org.apache.camel.spi.RecoverableAggregationRepository, org.apache.camel.StatefulService, org.apache.camel.SuspendableService
    Direct Known Subclasses:
    NamedCassandraAggregationRepository

    public class CassandraAggregationRepository
    extends org.apache.camel.support.service.ServiceSupport
    implements org.apache.camel.spi.RecoverableAggregationRepository
    Implementation of AggregationRepository using Cassandra table to store exchanges. Advice: use LeveledCompaction for this table and tune read/write consistency levels. Warning: Cassandra is not the best tool for queuing use cases See: http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets
    • Constructor Detail

      • CassandraAggregationRepository

        public CassandraAggregationRepository()
      • CassandraAggregationRepository

        public CassandraAggregationRepository​(com.datastax.oss.driver.api.core.CqlSession session)
    • Method Detail

      • getPKValues

        protected Object[] getPKValues​(String key)
        Generate primary key values from aggregation key.
      • doStart

        protected void doStart()
                        throws Exception
        Overrides:
        doStart in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • doStop

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.apache.camel.support.service.BaseService
        Throws:
        Exception
      • add

        public org.apache.camel.Exchange add​(org.apache.camel.CamelContext camelContext,
                                             String key,
                                             org.apache.camel.Exchange exchange)
        Insert or update exchange in aggregation table.
        Specified by:
        add in interface org.apache.camel.spi.AggregationRepository
      • initSelectStatement

        protected void initSelectStatement()
      • get

        public org.apache.camel.Exchange get​(org.apache.camel.CamelContext camelContext,
                                             String key)
        Get exchange from aggregation table by aggregation key.
        Specified by:
        get in interface org.apache.camel.spi.AggregationRepository
      • confirm

        public void confirm​(org.apache.camel.CamelContext camelContext,
                            String exchangeId)
        Remove exchange by Id from aggregation table.
        Specified by:
        confirm in interface org.apache.camel.spi.AggregationRepository
      • remove

        public void remove​(org.apache.camel.CamelContext camelContext,
                           String key,
                           org.apache.camel.Exchange exchange)
        Remove exchange by aggregation key from aggregation table.
        Specified by:
        remove in interface org.apache.camel.spi.AggregationRepository
      • selectKeyIds

        protected List<com.datastax.oss.driver.api.core.cql.Row> selectKeyIds()
      • getKeys

        public Set<String> getKeys()
        Get aggregation exchangeIds from aggregation table.
        Specified by:
        getKeys in interface org.apache.camel.spi.AggregationRepository
      • scan

        public Set<String> scan​(org.apache.camel.CamelContext camelContext)
        Get exchange IDs to be recovered
        Specified by:
        scan in interface org.apache.camel.spi.RecoverableAggregationRepository
        Returns:
        Exchange IDs
      • recover

        public org.apache.camel.Exchange recover​(org.apache.camel.CamelContext camelContext,
                                                 String exchangeId)
        Get exchange by exchange ID. This is far from optimal.
        Specified by:
        recover in interface org.apache.camel.spi.RecoverableAggregationRepository
      • getSession

        public com.datastax.oss.driver.api.core.CqlSession getSession()
      • setSession

        public void setSession​(com.datastax.oss.driver.api.core.CqlSession session)
      • getTable

        public String getTable()
      • setTable

        public void setTable​(String table)
      • getPrefixPKValues

        public Object[] getPrefixPKValues()
      • setPrefixPKValues

        public void setPrefixPKValues​(Object... prefixPKValues)
      • getPKColumns

        public String[] getPKColumns()
      • setPKColumns

        public void setPKColumns​(String... pkColumns)
      • getExchangeIdColumn

        public String getExchangeIdColumn()
      • setExchangeIdColumn

        public void setExchangeIdColumn​(String exchangeIdColumn)
      • getWriteConsistencyLevel

        public com.datastax.oss.driver.api.core.ConsistencyLevel getWriteConsistencyLevel()
      • setWriteConsistencyLevel

        public void setWriteConsistencyLevel​(com.datastax.oss.driver.api.core.ConsistencyLevel writeConsistencyLevel)
      • getReadConsistencyLevel

        public com.datastax.oss.driver.api.core.ConsistencyLevel getReadConsistencyLevel()
      • setReadConsistencyLevel

        public void setReadConsistencyLevel​(com.datastax.oss.driver.api.core.ConsistencyLevel readConsistencyLevel)
      • getExchangeColumn

        public String getExchangeColumn()
      • setExchangeColumn

        public void setExchangeColumn​(String exchangeColumnName)
      • setTtl

        public void setTtl​(Integer ttl)
      • getRecoveryIntervalInMillis

        public long getRecoveryIntervalInMillis()
        Specified by:
        getRecoveryIntervalInMillis in interface org.apache.camel.spi.RecoverableAggregationRepository
      • setRecoveryIntervalInMillis

        public void setRecoveryIntervalInMillis​(long recoveryIntervalInMillis)
      • setRecoveryInterval

        public void setRecoveryInterval​(long interval,
                                        TimeUnit timeUnit)
        Specified by:
        setRecoveryInterval in interface org.apache.camel.spi.RecoverableAggregationRepository
      • setRecoveryInterval

        public void setRecoveryInterval​(long recoveryIntervalInMillis)
        Specified by:
        setRecoveryInterval in interface org.apache.camel.spi.RecoverableAggregationRepository
      • isUseRecovery

        public boolean isUseRecovery()
        Specified by:
        isUseRecovery in interface org.apache.camel.spi.RecoverableAggregationRepository
      • setUseRecovery

        public void setUseRecovery​(boolean useRecovery)
        Specified by:
        setUseRecovery in interface org.apache.camel.spi.RecoverableAggregationRepository
      • getDeadLetterUri

        public String getDeadLetterUri()
        Specified by:
        getDeadLetterUri in interface org.apache.camel.spi.RecoverableAggregationRepository
      • setDeadLetterUri

        public void setDeadLetterUri​(String deadLetterUri)
        Specified by:
        setDeadLetterUri in interface org.apache.camel.spi.RecoverableAggregationRepository
      • getMaximumRedeliveries

        public int getMaximumRedeliveries()
        Specified by:
        getMaximumRedeliveries in interface org.apache.camel.spi.RecoverableAggregationRepository
      • setMaximumRedeliveries

        public void setMaximumRedeliveries​(int maximumRedeliveries)
        Specified by:
        setMaximumRedeliveries in interface org.apache.camel.spi.RecoverableAggregationRepository
      • isAllowSerializedHeaders

        public boolean isAllowSerializedHeaders()
      • setAllowSerializedHeaders

        public void setAllowSerializedHeaders​(boolean allowSerializedHeaders)