Packages

c

akka.cluster.sharding.typed.javadsl

EventSourcedEntity

abstract class EventSourcedEntity[Command, Event, State >: Null] extends EventSourcedBehavior[Command, Event, State]

Any Behavior can be used as a sharded entity actor, but the combination of sharding and persistent actors is very common and therefore this PersistentEntity class is provided as convenience.

It is a EventSourcedBehavior and is implemented in the same way. It selects the persistenceId automatically from the EntityTypeKey and entityId constructor parameters by using EntityTypeKey.persistenceIdFrom.

Source
EventSourcedEntity.scala
Linear Supertypes
EventSourcedBehavior[Command, Event, State], DeferredBehavior[Command], Behavior[Command], AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. EventSourcedEntity
  2. EventSourcedBehavior
  3. DeferredBehavior
  4. Behavior
  5. AnyRef
  6. Any
Implicitly
  1. by BehaviorDecorators
  2. by BehaviorDecorators
  3. by any2stringadd
  4. by StringFormat
  5. by Ensuring
  6. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new EventSourcedEntity(entityTypeKey: EntityTypeKey[Command], entityId: String, onPersistFailure: BackoffSupervisorStrategy)
  2. new EventSourcedEntity(entityTypeKey: EntityTypeKey[Command], entityId: String)

Concrete Value Members

  1. def apply(context: TypedActorContext[Command]): Behavior[Command]

    INTERNAL API: DeferredBehavior init

    INTERNAL API: DeferredBehavior init

    Definition Classes
    EventSourcedBehavior → DeferredBehavior
    Annotations
    @InternalApi()
  2. val entityId: String
  3. val entityTypeKey: EntityTypeKey[Command]
  4. def eventAdapter(): EventAdapter[Event, _]
    Definition Classes
    EventSourcedBehavior
  5. final def narrow[U <: Command]: Behavior[U]

    Narrow the type of this Behavior, which is always a safe operation.

    Narrow the type of this Behavior, which is always a safe operation. This method is necessary to implement the contravariant nature of Behavior (which cannot be expressed directly due to type inference problems).

    Definition Classes
    Behavior
  6. def onRecoveryCompleted(state: State): Unit

    The callback function is called to notify the actor that the recovery process is finished.

    The callback function is called to notify the actor that the recovery process is finished.

    Definition Classes
    EventSourcedBehavior
  7. def onRecoveryFailure(failure: Throwable): Unit

    The callback function is called to notify the actor that the recovery process has failed

    The callback function is called to notify the actor that the recovery process has failed

    Definition Classes
    EventSourcedBehavior
  8. def onSnapshot(meta: SnapshotMetadata, result: Optional[Throwable]): Unit

    Override to get notified when a snapshot is finished.

    Override to get notified when a snapshot is finished.

    result

    None if successful otherwise contains the exception thrown when snapshotting

    Definition Classes
    EventSourcedBehavior
  9. final def orElse(that: Behavior[Command]): Behavior[Command]

    Composes this Behavior with a fallback Behavior which is used when this Behavior doesn't handle the message or signal, i.e. when unhandled is returned.

    Composes this Behavior with a fallback Behavior which is used when this Behavior doesn't handle the message or signal, i.e. when unhandled is returned.

    that

    the fallback Behavior

    Definition Classes
    Behavior
  10. val persistenceId: PersistenceId
    Definition Classes
    EventSourcedBehavior
  11. def shouldSnapshot(state: State, event: Event, sequenceNr: Long): Boolean

    Initiates a snapshot if the given function returns true.

    Initiates a snapshot if the given function returns true. When persisting multiple events at once the snapshot is triggered after all the events have been persisted.

    receives the State, Event and the sequenceNr used for the Event

    returns

    true if snapshot should be saved for the given event

    Definition Classes
    EventSourcedBehavior
    See also

    EventSourcedBehavior#snapshotEvery

  12. def snapshotEvery(): Long

    Override and define that snapshot should be saved every N events.

    Override and define that snapshot should be saved every N events.

    If this is overridden shouldSnapshot is not used.

    returns

    number of events between snapshots, should be greater than 0

    Definition Classes
    EventSourcedBehavior
    See also

    EventSourcedBehavior#shouldSnapshot

  13. def tagsFor(event: Event): Set[String]

    The tagger function should give event tags, which will be used in persistence query

    The tagger function should give event tags, which will be used in persistence query

    Definition Classes
    EventSourcedBehavior

Shadowed Implicit Value Members

  1. val behavior: Behavior[Command]
    Implicit
    This member is added by an implicit conversion from EventSourcedEntity[Command, Event, State] to BehaviorDecorators[Command] performed by method BehaviorDecorators in akka.actor.typed.Behavior.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (eventSourcedEntity: BehaviorDecorators[Command]).behavior
    Definition Classes
    BehaviorDecorators
  2. val behavior: Behavior[Command]
    Implicit
    This member is added by an implicit conversion from EventSourcedEntity[Command, Event, State] to BehaviorDecorators[Command] performed by method BehaviorDecorators in akka.actor.typed.Behavior.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (eventSourcedEntity: BehaviorDecorators[Command]).behavior
    Definition Classes
    BehaviorDecorators
  3. def widen[U](matcher: PartialFunction[U, Command]): Behavior[U]

    Widen the wrapped Behavior by placing a funnel in front of it: the supplied PartialFunction decides which message to pull in (those that it is defined at) and may transform the incoming message to place them into the wrapped Behavior’s type hierarchy.

    Widen the wrapped Behavior by placing a funnel in front of it: the supplied PartialFunction decides which message to pull in (those that it is defined at) and may transform the incoming message to place them into the wrapped Behavior’s type hierarchy. Signals are not transformed.

    Example:

    receive[String] { (ctx, msg) => println(msg); same }.widen[Number] {
      case b: BigDecimal => s"BigDecimal($b)"
      case i: BigInteger => s"BigInteger($i)"
      // all other kinds of Number will be `unhandled`
    }

    Scheduled messages via akka.actor.typed.scaladsl.TimerScheduler can currently not be used together with widen, see issue #25318.

    Implicit
    This member is added by an implicit conversion from EventSourcedEntity[Command, Event, State] to BehaviorDecorators[Command] performed by method BehaviorDecorators in akka.actor.typed.Behavior.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (eventSourcedEntity: BehaviorDecorators[Command]).widen(matcher)
    Definition Classes
    BehaviorDecorators
  4. def widen[U](matcher: PartialFunction[U, Command]): Behavior[U]

    Widen the wrapped Behavior by placing a funnel in front of it: the supplied PartialFunction decides which message to pull in (those that it is defined at) and may transform the incoming message to place them into the wrapped Behavior’s type hierarchy.

    Widen the wrapped Behavior by placing a funnel in front of it: the supplied PartialFunction decides which message to pull in (those that it is defined at) and may transform the incoming message to place them into the wrapped Behavior’s type hierarchy. Signals are not transformed.

    Example:

    receive[String] { (ctx, msg) => println(msg); same }.widen[Number] {
      case b: BigDecimal => s"BigDecimal($b)"
      case i: BigInteger => s"BigInteger($i)"
      // all other kinds of Number will be `unhandled`
    }

    Scheduled messages via akka.actor.typed.scaladsl.TimerScheduler can currently not be used together with widen, see issue #25318.

    Implicit
    This member is added by an implicit conversion from EventSourcedEntity[Command, Event, State] to BehaviorDecorators[Command] performed by method BehaviorDecorators in akka.actor.typed.Behavior.
    Shadowing
    This implicitly inherited member is ambiguous. One or more implicitly inherited members have similar signatures, so calling this member may produce an ambiguous implicit conversion compiler error.
    To access this member you can use a type ascription:
    (eventSourcedEntity: BehaviorDecorators[Command]).widen(matcher)
    Definition Classes
    BehaviorDecorators