According to the definition, Apache Cassandra is a free and open source, distributed NoSQL database management system designed to handle large amounts of data across many commodity servers, providing high availability with no single point of failure. This recipe shows how to connect Kafka and Cassandra.
This recipe uses a Kafka-Cassandra connector published on Maven Central by Tuplejump.
It can be defined as a dependency in the build file. For example, with SBT:
libraryDependencies += "com.tuplejump" %% "kafka-connect-cassandra" % "0.0.7"
Data can be fetched from Cassandra in two modes:
- Bulk
- Timestamp-based
The modes change automatically based on the query. For example, bulk:
SELECT * FROM userlog;
For example, timestamp-based:
SELECT * FROM userlog WHERE ts > previousTime(); SELECT * FROM userlog WHERE ts = currentTime(); SELECT * FROM userlog WHERE ts >= previousTime() AND ts <= currentTime() ;