Interface Eventsourced

    • Method Detail

      • super$aroundPreStart

        void super$aroundPreStart()
      • super$aroundPreRestart

        void super$aroundPreRestart​(java.lang.Throwable reason,
                                    scala.Option<java.lang.Object> message)
        INTERNAL API.
      • super$aroundPostRestart

        void super$aroundPostRestart​(java.lang.Throwable reason)
        INTERNAL API.
      • super$aroundPostStop

        void super$aroundPostStop()
        INTERNAL API.
      • super$unhandled

        void super$unhandled​(java.lang.Object message)
      • super$stash

        void super$stash()
        Returns true if this persistent actor has successfully finished recovery.
      • super$aroundReceive

        void super$aroundReceive​(scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> receive,
                                 java.lang.Object msg)
        Processes a loaded snapshot, if any. A loaded snapshot is offered with a SnapshotOffer message to the actor's receiveRecover. Then initiates a message replay, either starting from the loaded snapshot or from scratch, and switches to recoveryStarted state. All incoming messages are stashed.

        Parameters:
        replayMax - maximum number of messages to replay.
        timeout - recovery event timeout
      • journalBatch_$eq

        void journalBatch_$eq​(scala.collection.immutable.Vector<PersistentEnvelope> x$1)
      • writeInProgress_$eq

        void writeInProgress_$eq​(boolean x$1)
      • sequenceNr_$eq

        void sequenceNr_$eq​(long x$1)
      • _lastSequenceNr_$eq

        void _lastSequenceNr_$eq​(long x$1)
      • pendingStashingPersistInvocations_$eq

        void pendingStashingPersistInvocations_$eq​(long x$1)
      • eventBatch_$eq

        void eventBatch_$eq​(scala.collection.immutable.List<PersistentEnvelope> x$1)
      • snapshotterId

        java.lang.String snapshotterId()
        Returns persistenceId.
        Specified by:
        snapshotterId in interface Snapshotter
      • lastSequenceNr

        long lastSequenceNr()
        Highest received sequence number so far or 0L if this actor hasn't replayed or stored any persistent events yet.
      • onReplaySuccess

        void onReplaySuccess()
        INTERNAL API. Called whenever a message replay succeeds. May be implemented by subclass.
      • onRecoveryFailure

        void onRecoveryFailure​(java.lang.Throwable cause,
                               scala.Option<java.lang.Object> event)
        Called whenever a message replay fails. By default it logs the error.

        Subclass may override to customize logging.

        The actor is always stopped after this method has been invoked.

        Parameters:
        cause - failure cause.
        event - the event that was processed in receiveRecover, if the exception was thrown there
      • onPersistFailure

        void onPersistFailure​(java.lang.Throwable cause,
                              java.lang.Object event,
                              long seqNr)
        Called when persist fails. By default it logs the error. Subclass may override to customize logging and for example send negative acknowledgment to sender.

        The actor is always stopped after this method has been invoked.

        Note that the event may or may not have been saved, depending on the type of failure.

        Parameters:
        cause - failure cause.
        event - the event that was to be persisted
      • onPersistRejected

        void onPersistRejected​(java.lang.Throwable cause,
                               java.lang.Object event,
                               long seqNr)
        Called when the journal rejected persist of an event. The event was not stored. By default this method logs the problem as an error, and the actor continues. The callback handler that was passed to the persist method will not be invoked.

        Parameters:
        cause - failure cause
        event - the event that was to be persisted
      • stashInternally

        void stashInternally​(java.lang.Object currMsg)
      • unstashInternally

        void unstashInternally​(boolean all)
      • startRecovery

        void startRecovery​(Recovery recovery)
      • aroundReceive

        void aroundReceive​(scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> receive,
                           java.lang.Object message)
        INTERNAL API.
        Specified by:
        aroundReceive in interface Actor
        Parameters:
        receive - current behavior.
        message - current message.
      • aroundPreStart

        void aroundPreStart()
        INTERNAL API.
        Specified by:
        aroundPreStart in interface Actor
      • requestRecoveryPermit

        void requestRecoveryPermit()
      • aroundPreRestart

        void aroundPreRestart​(java.lang.Throwable reason,
                              scala.Option<java.lang.Object> message)
        INTERNAL API.
        Specified by:
        aroundPreRestart in interface Actor
      • aroundPostRestart

        void aroundPostRestart​(java.lang.Throwable reason)
        INTERNAL API.
        Specified by:
        aroundPostRestart in interface Actor
      • aroundPostStop

        void aroundPostStop()
        INTERNAL API.
        Specified by:
        aroundPostStop in interface Actor
      • unhandled

        void unhandled​(java.lang.Object message)
        Description copied from interface: Actor
        User overridable callback.

        Is called when a message isn't handled by the current behavior of the actor by default it fails with either a pekko.actor.DeathPactException (in case of an unhandled pekko.actor.Terminated message) or publishes an pekko.actor.UnhandledMessage to the actor's system's pekko.event.EventStream
        Specified by:
        unhandled in interface Actor
      • updateLastSequenceNr

        void updateLastSequenceNr​(PersistentRepr persistent)
      • setLastSequenceNr

        void setLastSequenceNr​(long value)
      • nextSequenceNr

        long nextSequenceNr()
      • flushJournalBatch

        void flushJournalBatch()
      • sendBatchedEventsToJournal

        void sendBatchedEventsToJournal​(scala.collection.immutable.Vector<PersistentEnvelope> journalBatch)
      • receiveRecover

        scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> receiveRecover()
        Recovery handler that receives persisted events during recovery. If a state snapshot has been captured and saved, this handler will receive a pekko.persistence.SnapshotOffer message followed by events that are younger than the offered snapshot.

        This handler must not have side-effects other than changing persistent actor state i.e. it should not perform actions that may fail, such as interacting with external services, for example.

        If there is a problem with recovering the state of the actor from the journal, the error will be logged and the actor will be stopped.

        See Also:
        pekko.persistence.Recovery
      • receiveCommand

        scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> receiveCommand()
        Command handler. Typically validates commands against current state (and/or by communication with other actors). On successful validation, one or more events are derived from a command and these events are then persisted by calling persist.
      • internalPersist

        <A> void internalPersist​(A event,
                                 scala.Function1<A,​scala.runtime.BoxedUnit> handler)
        Internal API
      • internalPersistAll

        <A> void internalPersistAll​(scala.collection.immutable.Seq<A> events,
                                    scala.Function1<A,​scala.runtime.BoxedUnit> handler)
        Internal API
      • batchAtomicWrite

        void batchAtomicWrite​(AtomicWrite atomicWrite)
      • internalPersistAsync

        <A> void internalPersistAsync​(A event,
                                      scala.Function1<A,​scala.runtime.BoxedUnit> handler)
        Internal API
      • internalPersistAllAsync

        <A> void internalPersistAllAsync​(scala.collection.immutable.Seq<A> events,
                                         scala.Function1<A,​scala.runtime.BoxedUnit> handler)
        Internal API
      • internalDeferAsync

        <A> void internalDeferAsync​(A event,
                                    scala.Function1<A,​scala.runtime.BoxedUnit> handler)
        Internal API
      • internalDefer

        <A> void internalDefer​(A event,
                               scala.Function1<A,​scala.runtime.BoxedUnit> handler)
        Internal API
      • deleteMessages

        void deleteMessages​(long toSequenceNr)
        Permanently deletes all persistent messages with sequence numbers less than or equal toSequenceNr.

        If the delete is successful a pekko.persistence.DeleteMessagesSuccess will be sent to the actor. If the delete fails a pekko.persistence.DeleteMessagesFailure will be sent to the actor.

        The given toSequenceNr must be less than or equal to lastSequenceNr(), otherwise pekko.persistence.DeleteMessagesFailure is sent to the actor without performing the delete. All persistent messages may be deleted without specifying the actual sequence number by using Long.MaxValue as the toSequenceNr.

        Parameters:
        toSequenceNr - upper sequence number (inclusive) bound of persistent messages to be deleted.
      • internalDeleteMessagesBeforeSnapshot

        void internalDeleteMessagesBeforeSnapshot​(SaveSnapshotSuccess e,
                                                  int keepNrOfBatches,
                                                  int snapshotAfter)
        INTERNAL API. An Eventsourced actor can request cleanup by deleting either a range of, or all persistent events. For example, on successful snapshot completion, delete messages within a configurable snapshotAfter range that are less than or equal to the given SnapshotMetadata.sequenceNr (provided the SnapshotMetadata.sequenceNr is <= to lastSequenceNr()).

        Or delete all by using Long.MaxValue as the toSequenceNr

         m.copy(sequenceNr = Long.MaxValue) 
      • recoveryRunning

        boolean recoveryRunning()
        Returns true if this persistent actor is currently recovering.
      • recoveryFinished

        boolean recoveryFinished()
        Returns true if this persistent actor has successfully finished recovery.
      • stash

        void stash()
        Description copied from interface: StashSupport
        Adds the current message (the message that the actor received last) to the actor's stash.

        Specified by:
        stash in interface StashSupport
      • unstashAll

        void unstashAll()
        Description copied from interface: StashSupport
        Prepends all messages in the stash to the mailbox, and then clears the stash.

        Messages from the stash are enqueued to the mailbox until the capacity of the mailbox (if any) has been reached. In case a bounded mailbox overflows, a MessageQueueAppendFailedException is thrown.

        The stash is guaranteed to be empty after calling unstashAll().

        Specified by:
        unstashAll in interface StashSupport
      • waitingRecoveryPermit

        java.lang.Object waitingRecoveryPermit​(Recovery recovery)
      • recoveryStarted

        java.lang.Object recoveryStarted​(long replayMax,
                                         scala.concurrent.duration.FiniteDuration timeout)
      • recovering

        java.lang.Object recovering​(scala.PartialFunction<java.lang.Object,​scala.runtime.BoxedUnit> recoveryBehavior,
                                    scala.concurrent.duration.FiniteDuration timeout)
      • flushBatch

        void flushBatch()
      • peekApplyHandler

        void peekApplyHandler​(java.lang.Object payload)
      • writeEventRejected

        void writeEventRejected​(PersistentRepr p,
                                java.lang.Throwable cause)
      • writeEventFailed

        void writeEventFailed​(PersistentRepr p,
                              java.lang.Throwable cause)