niqdev / akka-stream-cassandra

Streaming library for old versions of Cassandra

Website GitHub

akka-stream-cassandra

Build Status Coverage Status Download Scaladoc

Akka Stream based library for unsupported and no longer maintained versions of Cassandra and DataStax Enterprise powered by Netflix Astyanax

Please prefer alpakka Cassandra Connector for version 2 and above

Have a look at the presentation of this lightning talk about Cassandra migration to understand the reason behind this library

Setup

Add the jcenter repository in your build definition and import the latest stable version

resolvers += Resolver.jcenterRepo

libraryDependencies ++= Seq(
  "com.github.niqdev" %% "akka-stream-cassandra" % "0.7.5"
    // you might prefer to use a different version
    exclude("com.netflix.astyanax", "astyanax")
)

Example

implicit val actorSystem: ActorSystem = ActorSystem("actor-system")
implicit val materializer: ActorMaterializer = ActorMaterializer()
implicit val executionContext: ExecutionContext = actorSystem.dispatcher

val keyspace: Keyspace = ...
val columnFamily: ColumnFamily[String, String] = ...

CassandraSource(keyspace, columnFamily)
  .via(...)
  .runForeach { row =>
    log.debug(s"row: ${row.getKey}")
  }

Refer to the test for a full example with EmbeddedCassandra