...
Available as of Camel 2.15
Apache Cassandra is an open source NoSQL database designed to handle large amounts on commodity hardware. Like Amazon's DynamoDB, Cassandra has a peer-to-peer and master-less architecture to avoid single point of failure and garanty high availability. Like Google's BigTable, Cassandra data is structured using column families which can be accessed through the Thrift RPC API or a SQL-like API called CQL.
...
Maven users will need to add the following dependency to their pom.xml
for this component:
Code Block | ||||
---|---|---|---|---|
| ||||
<dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-cassandraql</artifactId> <version>x.y.z</version> <!-- use the same version as your Camel core version --> </dependency> |
...
To fine tune the Cassandra connection (SSL options, pooling options, load balancing policy, retry policy, reconnection policy...), create your own Cluster instance and give it to the Camel endpoint.
Endpoint Options
Option | Default | Description |
---|---|---|
clusterName | Cluster name | |
| Session authentication | |
| CQL query. Can be overriden with a message header. | |
|
| |
| ALL | How is ResultSet converted transformed into message body |
Messages
Incoming Message
The Camel Cassandra endpoint expects a bunch of simple objects (Object[] or Collection<Object>) which will be bound to the CQL statement as query parameters.
...
CamelCqlQuery
(optional, String): CQL query
Outgoing Message
The Camel Cassandra endpoint produces one or many a Cassandra Row objects depending on the resultSetConversionStrategy:
...
Code Block | ||||
---|---|---|---|---|
| ||||
CREATE TABLE CAMEL_IDEMPOTENT (
NAME varchar, -- Repository name
KEY varchar, -- Message key
PRIMARY KEY (NAME, KEY)
) WITH compaction = {'class':'LeveledCompactionStrategy'}
AND gc_grace_seconds = 86400; |
This repository implementation uses lightweight transactions (also known as Compare and Set) and requires Cassandra 2.0.7+.
The CassandraIdempotentRepository can be extended to use a different data model.
Option | Default | Description |
---|---|---|
table | CAMEL_IDEMPOTENT | Table name |
pkColumns | NAME , KEY | Primary key columns |
name | Repository name, value used for NAME column | |
ttl | Key time to live | |
writeConsistencyLevel | Consistency level used to insert/delete key: ANY , ONE , TWO , QUORUM , LOCAL_QUORUM … | |
readConsistencyLevel | Consistency level used to read/check key: ONE , TWO , QUORUM , LOCAL_QUORUM … |
Aggregation repository
The name NamedCassandraAggregationRepository stores messages exchanges by correlation key in a Cassandra table like this:
Code Block | ||||
---|---|---|---|---|
| ||||
CREATE TABLE CAMEL_AGGREGATION (
NAME varchar, -- Repository name
KEY varchar, -- Correlation id
EXCHANGE_ID varchar, -- Exchange id
EXCHANGE blob, -- Serialized exchange
PRIMARY KEY (NAME, KEY)
) WITH compaction = {'class':'LeveledCompactionStrategy'}
AND gc_grace_seconds = 86400; |
The CassandraAggregationRepository can be extended to use a different data model.
Option | Default | Description |
---|---|---|
table | CAMEL_AGGREGATION | Table name |
pkColumns | NAME ,KEY | Primary key columns |
exchangeIdColumn | EXCHANGE_ID | Exchange Id column |
exchangeColumn | EXCHANGE | Exchange content column |
name | Repository name, value used for NAME column | |
ttl | Exchange time to live | |
writeConsistencyLevel | Consistency level used to insert/delete exchange: ANY , ONE , TWO , QUORUM , LOCAL_QUORUM … | |
readConsistencyLevel | Consistency level used to read/check exchange: ONE , TWO , QUORUM , LOCAL_QUORUM … |