Trait/Object

com.rbmhtechnology.eventuate

PersistOnEvent

Related Docs: object PersistOnEvent | package eventuate

Permalink

trait PersistOnEvent extends EventsourcedActor

Can be mixed into EventsourcedActor for writing new events within the onEvent handler. New events are written with the asynchronous persistOnEvent method. In contrast to persist, one can not prevent command processing from running concurrently to persistOnEvent by setting stateSync to true.

A persistOnEvent operation is reliable and idempotent. Once the event has been successfully written, a repeated persistOnEvent call for that event during event replay has no effect. A failed persistOnEvent operation will restart the actor by throwing a PersistOnEventException. After restart, failed persistOnEvent operations are automatically re-tried.

An EventsourcedActor that has a PersistOnEvent mixin is to some extend comparable to a StatefulProcessor that is configured to write events to its source event log. Both write new events on receiving events, however, a StatefulProcessor that writes new events to its source event log requires its own entry in the vector clock, whereas PersistOnEvent does not. Furthermore, a StatefulProcessor can not write new events during command processing. As a general rule, when operating on a single event log, applications should prefer PersistOnEvent over StatefulProcessor.

Linear Supertypes
EventsourcedActor, EventsourcedClock, EventsourcedView, ActorLogging, Stash, RequiresMessageQueue[DequeBasedMessageQueueSemantics], UnrestrictedStash, StashSupport, Actor, AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. PersistOnEvent
  2. EventsourcedActor
  3. EventsourcedClock
  4. EventsourcedView
  5. ActorLogging
  6. Stash
  7. RequiresMessageQueue
  8. UnrestrictedStash
  9. StashSupport
  10. Actor
  11. AnyRef
  12. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

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

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

    Permalink
    Definition Classes
    Actor

Abstract Value Members

  1. abstract def eventLog: ActorRef

    Permalink

    Event log actor.

    Event log actor.

    Definition Classes
    EventsourcedView
  2. abstract def id: String

    Permalink

    Global unique actor id.

    Global unique actor id.

    Definition Classes
    EventsourcedView
  3. abstract def onCommand: Receive

    Permalink

    Command handler.

    Command handler.

    Definition Classes
    EventsourcedView
  4. abstract def onEvent: Receive

    Permalink

    Event handler.

    Event handler.

    Definition Classes
    EventsourcedView

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.

    Definition Classes
    EventsourcedView
  5. def aroundPostRestart(reason: Throwable): Unit

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

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

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

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

    Permalink
    Attributes
    protected[akka]
    Definition Classes
    Actor
  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.

    Returns the command BehaviorContext.

    Definition Classes
    EventsourcedView
  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.

    Returns the event BehaviorContext.

    Definition Classes
    EventsourcedView
  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
    Definition Classes
    EventsourcedView
  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.

    Emitter aggregate id of the last handled event.

    Definition Classes
    EventsourcedView
  23. final def lastEmitterId: String

    Permalink

    Emitter id of the last handled event.

    Emitter id of the last handled event.

    Definition Classes
    EventsourcedView
  24. final def lastSequenceNr: Long

    Permalink

    Sequence number of the last handled event.

    Sequence number of the last handled event.

    Definition Classes
    EventsourcedView
  25. final def lastSystemTimestamp: Long

    Permalink

    Wall-clock timestamp of the last handled event.

    Wall-clock timestamp of the last handled event.

    Definition Classes
    EventsourcedView
  26. final def lastVectorTimestamp: VectorTime

    Permalink

    Vector timestamp of the last handled event.

    Vector timestamp of the last handled event.

    Definition Classes
    EventsourcedView
  27. def log: LoggingAdapter

    Permalink
    Definition Classes
    ActorLogging
  28. final def ne(arg0: AnyRef): Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  31. 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.

    Definition Classes
    EventsourcedView
  32. def onSnapshot: Receive

    Permalink

    Snapshot handler.

    Snapshot handler.

    Definition Classes
    EventsourcedView
  33. final def persist[A](event: A, customDestinationAggregateIds: Set[String] = Set())(handler: Handler[A]): Unit

    Permalink

    Asynchronously persists the given event and calls handler with the persist result.

    Asynchronously persists the given event and calls handler with the persist result. If persistence was successful, onEvent is called with the persisted event before handler is called. Both, onEvent and handler, are called on a dispatcher thread of this actor, hence, it is safe to modify internal state within them. The handler can also obtain a reference to the initial command sender via sender().

    By default, the event is routed to event-sourced destinations with an undefined aggregateId. If this actor's aggregateId is defined it is additionally routed to all actors with the same aggregateId. Further routing destinations can be defined with the customDestinationAggregateIds parameter.

    Definition Classes
    EventsourcedActor
  34. final def persistN[A](events: Seq[A], onLast: Handler[A] = (_: Try[A]) => (), customDestinationAggregateIds: Set[String] = Set())(handler: Handler[A]): Unit

    Permalink

    Asynchronously persists a sequence of events and calls handler with the persist result for each event in the sequence.

    Asynchronously persists a sequence of events and calls handler with the persist result for each event in the sequence. If persistence was successful, onEvent is called with a persisted event before handler is called. Both, onEvent and handler, are called on a dispatcher thread of this actor, hence, it is safe to modify internal state within them. The handler can also obtain a reference to the initial command sender via sender(). The onLast handler is additionally called for the last event in the sequence.

    By default, the event is routed to event-sourced destinations with an undefined aggregateId. If this actor's aggregateId is defined it is additionally routed to all actors with the same aggregateId. Further routing destinations can be defined with the customDestinationAggregateIds parameter.

    Definition Classes
    EventsourcedActor
  35. final def persistOnEvent[A](event: A, customDestinationAggregateIds: Set[String] = Set()): Unit

    Permalink

    Asynchronously persists the given event.

    Asynchronously persists the given event. Applications that want to handle the persisted event should define the event handler at that event. By default, the event is routed to event-sourced destinations with an undefined aggregateId. If this actor's aggregateId is defined it is additionally routed to all actors with the same aggregateId. Further routing destinations can be defined with the customDestinationAggregateIds parameter.

  36. def postRestart(reason: Throwable): Unit

    Permalink
    Definition Classes
    Actor
    Annotations
    @throws( classOf[java.lang.Exception] )
  37. 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
  38. 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
  39. def preStart(): Unit

    Permalink

    Initializes the vector clock and sets the clock's processId to the log id.

    Initializes the vector clock and sets the clock's processId to the log id.

    Definition Classes
    EventsourcedClockEventsourcedView → Actor
  40. final def receive: Receive

    Permalink

    Initialization behavior.

    Initialization behavior.

    Definition Classes
    EventsourcedView → Actor
  41. 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.

    Definition Classes
    EventsourcedView
  42. 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.

    Definition Classes
    EventsourcedView
  43. 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().

    Definition Classes
    EventsourcedView
  44. implicit final val self: ActorRef

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

    Permalink
    Definition Classes
    Actor
  46. def sharedClockEntry: Boolean

    Permalink

    If true, this actor shares a vector clock entry with those actors on the same local eventLog that have set sharedClockEntry to true as well.

    If true, this actor shares a vector clock entry with those actors on the same local eventLog that have set sharedClockEntry to true as well. Otherwise, this actor has its own entry in the vector clock.

    Definition Classes
    EventsourcedClock
  47. def snapshotContext: BehaviorContext

    Permalink

    Returns the snapshot BehaviorContext.

    Returns the snapshot BehaviorContext.

    Definition Classes
    EventsourcedView
  48. 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 or persist handler.

    Definition Classes
    EventsourcedActorEventsourcedView → StashSupport
  49. def stateSync: Boolean

    Permalink

    State synchronization.

    State synchronization. If set to true, commands see internal state that is consistent with the event log. This is achieved by stashing new commands if this actor is currently writing events. If set to false, commands see internal state that is eventually consistent with the event log.

    Definition Classes
    EventsourcedActor
  50. def supervisorStrategy: SupervisorStrategy

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

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

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

    Permalink
    Definition Classes
    Actor
  54. 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
    EventsourcedActorEventsourcedView → StashSupport
  55. final def wait(): Unit

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

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

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

Inherited from EventsourcedActor

Inherited from EventsourcedClock

Inherited from EventsourcedView

Inherited from ActorLogging

Inherited from Stash

Inherited from RequiresMessageQueue[DequeBasedMessageQueueSemantics]

Inherited from UnrestrictedStash

Inherited from StashSupport

Inherited from Actor

Inherited from AnyRef

Inherited from Any

Ungrouped