Packages

o

akka.projection.cassandra.scaladsl

CassandraProjection

object CassandraProjection

Factories of akka.projection.Projection where the offset is stored in Cassandra. The envelope handler can integrate with anything, such as publishing to a message broker, or updating a read model in Cassandra.

The envelope handler function can be stateful, with variables and mutable data structures. It is invoked by the Projection machinery one envelope at a time and visibility guarantees between the invocations are handled automatically, i.e. no volatile or other concurrency primitives are needed for managing the state.

Source
CassandraProjection.scala
Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. CassandraProjection
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Value Members

  1. def atLeastOnce[Offset, Envelope](projectionId: ProjectionId, sourceProvider: SourceProvider[Offset, Envelope], handler: () => Handler[Envelope]): AtLeastOnceProjection[Offset, Envelope]

    Create a akka.projection.Projection with at-least-once processing semantics.

    Create a akka.projection.Projection with at-least-once processing semantics. It stores the offset in Cassandra after the handler has processed the envelope. This means that if the projection is restarted from previously stored offset some envelopes may be processed more than once.

    The offset is stored after a time window, or limited by a number of envelopes, whatever happens first. This window can be defined with AtLeastOnceProjection.withSaveOffset of the returned AtLeastOnceCassandraProjection. The default settings for the window is defined in configuration section akka.projection.at-least-once.

  2. def atLeastOnceFlow[Offset, Envelope](projectionId: ProjectionId, sourceProvider: SourceProvider[Offset, Envelope], handler: FlowWithContext[Envelope, ProjectionContext, Done, ProjectionContext, _]): AtLeastOnceFlowProjection[Offset, Envelope]

    Create a akka.projection.Projection with a FlowWithContext as the envelope handler.

    Create a akka.projection.Projection with a FlowWithContext as the envelope handler. It has at-least-once processing semantics.

    The flow should emit a Done element for each completed envelope. The offset of the envelope is carried in the context of the FlowWithContext and is stored in Cassandra when corresponding Done is emitted. Since the offset is stored after processing the envelope it means that if the projection is restarted from previously stored offset then some envelopes may be processed more than once.

    If the flow filters out envelopes the corresponding offset will not be stored, and such envelope will be processed again if the projection is restarted and no later offset was stored.

    The flow should not duplicate emitted envelopes (mapConcat) with same offset, because then it can result in that the first offset is stored and when the projection is restarted that offset is considered completed even though more of the duplicated envelopes were never processed.

    The flow must not reorder elements, because the offsets may be stored in the wrong order and and when the projection is restarted all envelopes up to the latest stored offset are considered completed even though some of them may not have been processed. This is the reason the flow is restricted to FlowWithContext rather than ordinary Flow.

  3. def atMostOnce[Offset, Envelope](projectionId: ProjectionId, sourceProvider: SourceProvider[Offset, Envelope], handler: () => Handler[Envelope]): AtMostOnceProjection[Offset, Envelope]

    Create a akka.projection.Projection with at-most-once processing semantics.

    Create a akka.projection.Projection with at-most-once processing semantics. It stores the offset in Cassandra before the handler has processed the envelope. This means that if the projection is restarted from previously stored offset one envelope may not have been processed.

  4. def createTablesIfNotExists()(implicit system: ActorSystem[_]): Future[Done]

    For testing purposes the projection offset and management tables can be created programmatically.

    For testing purposes the projection offset and management tables can be created programmatically. For production it's recommended to create the table with DDL statements before the system is started.

  5. def groupedWithin[Offset, Envelope](projectionId: ProjectionId, sourceProvider: SourceProvider[Offset, Envelope], handler: () => Handler[Seq[Envelope]]): GroupedProjection[Offset, Envelope]

    Create a akka.projection.Projection that groups envelopes and calls the handler with a group of Envelopes.

    Create a akka.projection.Projection that groups envelopes and calls the handler with a group of Envelopes. The envelopes are grouped within a time window, or limited by a number of envelopes, whatever happens first. This window can be defined with GroupedProjection.withGroup of the returned GroupedCassandraProjection. The default settings for the window is defined in configuration section akka.projection.grouped.

    It stores the offset in Cassandra immediately after the handler has processed the envelopes, but that is still with at-least-once processing semantics. This means that if the projection is restarted from previously stored offset the previous group of envelopes may be processed more than once.

Deprecated Value Members

  1. def createOffsetTableIfNotExists()(implicit system: ActorSystem[_]): Future[Done]
    Annotations
    @deprecated
    Deprecated

    (Since version 1.2.0) Renamed to createTablesIfNotExists