Trait/Object

com.rbmhtechnology.eventuate

EventsourcedView

Related Docs: object EventsourcedView | package eventuate

Permalink

trait EventsourcedView extends Actor with Stash

An actor that derives internal state from events stored in an event log. Events are pushed from the eventLog actor to this actor and handled with the onEvent event handler. An event handler defines how internal state is updated from events.

An EventsourcedView can also store snapshots of internal state with its save method. During (re-)start the latest snapshot saved by this actor (if any) is passed as argument to the onSnapshot handler, if the handler is defined at that snapshot. If the onSnapshot handler is not defined at that snapshot or is not overridden at all, event replay starts from scratch. Newer events that are not covered by the snapshot are handled by onEvent after onSnapshot returns.

By default, an EventsourcedView does not define an aggregateId. In this case, the eventLog pushes all events to this actor. If it defines an aggregateId, the eventLog actor only pushes those events that contain that aggregateId value in their routingDestinations set.

An EventsourcedView can only consume events from its eventLog but cannot produce new events. Commands sent to an EventsourcedView during recovery are delayed until recovery completes.

Event replay is subject to backpressure. After a configurable number of events (see eventuate.log.replay-batch-size configuration parameter), replay is suspended until these events have been handled by onEvent and then resumed again. There's no backpressure mechanism for live event processing yet (but will come in future releases).

See also

EventsourcedProcessor

EventsourcedWriter

EventsourcedActor

DurableEvent

Linear Supertypes
Stash, RequiresMessageQueue[DequeBasedMessageQueueSemantics], UnrestrictedStash, StashSupport, Actor, AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. EventsourcedView
  2. Stash
  3. RequiresMessageQueue
  4. UnrestrictedStash
  5. StashSupport
  6. Actor
  7. AnyRef
  8. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. type Handler[A] = (Try[A]) ⇒ Unit

    Permalink
  2. type Receive = PartialFunction[Any, Unit]

    Permalink
    Definition Classes
    Actor

Abstract Value Members

  1. abstract def eventLog: ActorRef

    Permalink

    Event log actor.

  2. abstract def id: String

    Permalink

    Global unique actor id.

  3. abstract def onCommand: Receive

    Permalink

    Command handler.

  4. abstract def onEvent: Receive

    Permalink

    Event handler.

Concrete Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. def aggregateId: Option[String]

    Permalink

    Optional aggregate id.

    Optional aggregate id. It is used for routing DurableEvents to event-sourced destinations which can be EventsourcedViews or EventsourcedActors. By default, an event is routed to an event-sourced destination with an undefined aggregateId. If a destination's aggregateId is defined it will only receive events with a matching aggregate id in DurableEvent#destinationAggregateIds.

  5. def aroundPostRestart(reason: Throwable): Unit

    Permalink
    Attributes
    protected[akka]
    Definition Classes
    Actor
    Annotations
    @InternalApi()
  6. def aroundPostStop(): Unit

    Permalink
    Attributes
    protected[akka]
    Definition Classes
    Actor
    Annotations
    @InternalApi()
  7. def aroundPreRestart(reason: Throwable, message: Option[Any]): Unit

    Permalink
    Attributes
    protected[akka]
    Definition Classes
    Actor
    Annotations
    @InternalApi()
  8. def aroundPreStart(): Unit

    Permalink
    Attributes
    protected[akka]
    Definition Classes
    Actor
    Annotations
    @InternalApi()
  9. def aroundReceive(receive: akka.actor.Actor.Receive, msg: Any): Unit

    Permalink
    Attributes
    protected[akka]
    Definition Classes
    Actor
    Annotations
    @InternalApi()
  10. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  11. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def commandContext: BehaviorContext

    Permalink

    Returns the command BehaviorContext.

  13. implicit val context: ActorContext

    Permalink
    Definition Classes
    Actor
  14. final def eq(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  15. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  16. def eventContext: BehaviorContext

    Permalink

    Returns the event BehaviorContext.

  17. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  18. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  19. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  20. val instanceId: Int

    Permalink
  21. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  22. final def lastEmitterAggregateId: Option[String]

    Permalink

    Emitter aggregate id of the last handled event.

  23. final def lastEmitterId: String

    Permalink

    Emitter id of the last handled event.

  24. final def lastProcessId: String

    Permalink

    Id of the local event log that initially wrote the event.

  25. final def lastSequenceNr: Long

    Permalink

    Sequence number of the last handled event.

  26. final def lastSystemTimestamp: Long

    Permalink

    Wall-clock timestamp of the last handled event.

  27. final def lastVectorTimestamp: VectorTime

    Permalink

    Vector timestamp of the last handled event.

  28. val logger: LoggingAdapter

    Permalink

    This actor's logging adapter.

  29. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  30. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  31. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  32. def onRecovery: Handler[Unit]

    Permalink

    Recovery completion handler.

    Recovery completion handler. If called with a Failure, the actor will be stopped in any case, regardless of the action taken by the returned handler. The default handler implementation does nothing and can be overridden by implementations.

  33. def onSnapshot: Receive

    Permalink

    Snapshot handler.

  34. def postRestart(reason: Throwable): Unit

    Permalink
    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  35. def postStop(): Unit

    Permalink

    Sets recovering to false before calling super.postStop.

    Sets recovering to false before calling super.postStop.

    Definition Classes
    EventsourcedView → UnrestrictedStash → Actor
  36. def preRestart(reason: Throwable, message: Option[Any]): Unit

    Permalink

    Sets recovering to false before calling super.preRestart.

    Sets recovering to false before calling super.preRestart.

    Definition Classes
    EventsourcedView → UnrestrictedStash → Actor
  37. def preStart(): Unit

    Permalink

    Initiates recovery.

    Initiates recovery.

    Definition Classes
    EventsourcedView → Actor
  38. final def receive: Receive

    Permalink

    Initialization behavior.

    Initialization behavior.

    Definition Classes
    EventsourcedView → Actor
  39. final def recovering: Boolean

    Permalink

    Returns true if this actor is currently recovering internal state by consuming replayed events from the event log.

    Returns true if this actor is currently recovering internal state by consuming replayed events from the event log. Returns false after recovery completed and the actor switches to consuming live events.

  40. def replayBatchSize: Int

    Permalink

    Maximum number of events to be replayed to this actor before replaying is suspended.

    Maximum number of events to be replayed to this actor before replaying is suspended. A suspended replay is resumed automatically after all replayed events haven been handled by this actor's event handler (= backpressure). The default value for the maximum replay batch size is given by configuration item eventuate.log.replay-batch-size. Configured values can be overridden by overriding this method.

  41. def replayFromSequenceNr: Option[Long]

    Permalink

    Override to provide an application-defined log sequence number from which event replay will start.

    Override to provide an application-defined log sequence number from which event replay will start.

    If Some(snr) is returned snapshot loading will be skipped and replay will start from the given sequence number snr.

    If None is returned the actor proceeds with the regular snapshot loading procedure.

  42. final def save(snapshot: Any)(handler: Handler[SnapshotMetadata]): Unit

    Permalink

    Asynchronously saves the given snapshot and calls handler with the generated snapshot metadata.

    Asynchronously saves the given snapshot and calls handler with the generated snapshot metadata. The handler can obtain a reference to the initial message sender with sender().

  43. implicit final val self: ActorRef

    Permalink
    Definition Classes
    Actor
  44. final def sender(): ActorRef

    Permalink
    Definition Classes
    Actor
  45. def snapshotContext: BehaviorContext

    Permalink

    Returns the snapshot BehaviorContext.

  46. def stash(): Unit

    Permalink

    Adds the current command to the user's command stash.

    Adds the current command to the user's command stash. Must not be used in the event handler.

    Definition Classes
    EventsourcedView → StashSupport
  47. def supervisorStrategy: SupervisorStrategy

    Permalink
    Definition Classes
    Actor
  48. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  49. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  50. def unhandled(message: Any): Unit

    Permalink
    Definition Classes
    Actor
  51. def unstashAll(): Unit

    Permalink

    Prepends all stashed commands to the actor's mailbox and then clears the command stash.

    Prepends all stashed commands to the actor's mailbox and then clears the command stash. Has no effect if the actor is recovering i.e. if recovering returns true.

    Definition Classes
    EventsourcedView → StashSupport
  52. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  53. final def wait(arg0: Long, arg1: Int): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  54. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from Stash

Inherited from RequiresMessageQueue[DequeBasedMessageQueueSemantics]

Inherited from UnrestrictedStash

Inherited from StashSupport

Inherited from Actor

Inherited from AnyRef

Inherited from Any

Ungrouped