An Akka extension for using Apache Cassandra as event log storage backend.
An Akka extension for using Apache Cassandra as event log storage backend. The extension connects to the configured Cassandra cluster and creates the configured keyspace if it doesn't exist yet. Keyspace auto-creation can be turned off by setting
eventuate.log.cassandra.keyspace-autocreate = false
The name of the keyspace defaults to eventuate
and can be configured with
eventuate.log.cassandra.keyspace = "eventuate"
The Cassandra cluster contact points can be configured with
eventuate.log.cassandra.contact-points = [host1[:port1], host2[:port2], ...]
Ports are optional and default to 9042
according to
eventuate.log.cassandra.default-port = 9042
This extension also creates two index tables for storing replication progress data and event log indexing progress data. The names of these tables have a prefix defined by
eventuate.log.cassandra.table-prefix = "log"
Assuming a log
prefix
log_rp
andlog_snr
.If two instances of this extensions are created concurrently by two different actor systems, index table
creation can fail (see CASSANDRA-8387). It is
therefore recommended to initialize a clean Cassandra cluster with a separate administrative application
that only creates an instance of this Akka extension before creating CassandraEventLog actors. This
must be done only once. Alternatively, different actor systems can be configured with different
eventuate.log.cassandra.keyspace
names. In this case they won't share a keyspace and index tables and
concurrent initialization is not an issue.
An event log actor with Apache Cassandra as storage backend.
An event log actor with Apache Cassandra as storage backend. It uses
the Cassandra extension to connect to a Cassandra cluster. Applications should create an instance
of this actor using the props
method of the CassandraEventLog
companion object.
val factory: ActorRefFactory = ... // ActorSystem or ActorContext val logId: String = "example" // Unique log id val log = factory.actorOf(CassandraEventLog.props(logId))
Each event log actor creates two tables in the configured keyspace (see also Cassandra). Assuming the following table prefix
eventuate.log.cassandra.table-prefix = "log"
and a log id
with value example
, the names of these two tables are
log_example
which represents the local event log.log_example_agg
which is an index of the local event log for those events that have non-empty
destinationAggregateIds set. It is used for fast recovery
of event-sourced actors, views, stateful writers and processors that have an
aggregateId defined.
Internal state of CassandraEventLog.