public interface AtLeastOnceDelivery extends PersistentActor, AtLeastOnceDeliveryLike
PersistentActor
to send messages with at-least-once
delivery semantics to destinations. It takes care of re-sending messages when they
have not been confirmed within a configurable timeout. Use the AtLeastOnceDeliveryLike.deliver(akka.actor.ActorPath, scala.Function1<java.lang.Object, java.lang.Object>)
method to
send a message to a destination. Call the AtLeastOnceDeliveryLike.confirmDelivery(long)
method when the destination
has replied with a confirmation message.
At-least-once delivery implies that original message send order is not always retained and the destination may receive duplicate messages due to possible resends.
The interval between redelivery attempts can be defined by AtLeastOnceDeliveryLike.redeliverInterval()
.
After a number of delivery attempts a AtLeastOnceDelivery.UnconfirmedWarning
message
will be sent to self
. The re-sending will still continue, but you can choose to call
AtLeastOnceDeliveryLike.confirmDelivery(long)
to cancel the re-sending.
The AtLeastOnceDelivery
trait has a state consisting of unconfirmed messages and a
sequence number. It does not store this state itself. You must persist events corresponding
to the deliver
and confirmDelivery
invocations from your PersistentActor
so that the
state can be restored by calling the same methods during the recovery phase of the
PersistentActor
. Sometimes these events can be derived from other business level events,
and sometimes you must create separate events. During recovery calls to deliver
will not send out the message, but it will be sent later if no matching confirmDelivery
was performed.
Support for snapshots is provided by AtLeastOnceDeliveryLike.getDeliverySnapshot()
and AtLeastOnceDeliveryLike.setDeliverySnapshot(akka.persistence.AtLeastOnceDelivery.AtLeastOnceDeliverySnapshot)
.
The AtLeastOnceDeliverySnapshot
contains the full delivery state, including unconfirmed messages.
If you need a custom snapshot for other parts of the actor state you must also include the
AtLeastOnceDeliverySnapshot
. It is serialized using protobuf with the ordinary Akka
serialization mechanism. It is easiest to include the bytes of the AtLeastOnceDeliverySnapshot
as a blob in your custom snapshot.
AtLeastOnceDeliveryLike
Modifier and Type | Interface and Description |
---|---|
static class |
AtLeastOnceDelivery.AtLeastOnceDeliverySnapshot
Snapshot of current
AtLeastOnceDelivery state. |
static class |
AtLeastOnceDelivery.AtLeastOnceDeliverySnapshot$ |
static class |
AtLeastOnceDelivery.Internal$
INTERNAL API
|
static class |
AtLeastOnceDelivery.MaxUnconfirmedMessagesExceededException |
static class |
AtLeastOnceDelivery.UnconfirmedDelivery
Information about a message that has not been confirmed.
|
static class |
AtLeastOnceDelivery.UnconfirmedDelivery$ |
static class |
AtLeastOnceDelivery.UnconfirmedWarning |
static class |
AtLeastOnceDelivery.UnconfirmedWarning$ |
Eventsourced.AsyncHandlerInvocation, Eventsourced.AsyncHandlerInvocation$, Eventsourced.PendingHandlerInvocation, Eventsourced.RecoveryTick, Eventsourced.RecoveryTick$, Eventsourced.StashingHandlerInvocation, Eventsourced.StashingHandlerInvocation$, Eventsourced.State
receive
aroundPostStop, aroundPreRestart, aroundReceive, confirmDelivery, deliver, deliver, getDeliverySnapshot, maxUnconfirmedMessages, nextDeliverySequenceNr, numberOfUnconfirmed, onReplaySuccess, redeliverInterval, redeliverOverdue, redeliveryBurstLimit, send, setDeliverySnapshot, startRedeliverTask, warnAfterNumberOfUnconfirmedAttempts
aroundPostRestart, aroundPreStart, changeState, deferAsync, deleteMessages, flushBatch, flushJournalBatch, journal, lastSequenceNr, log, nextSequenceNr, onPersistFailure, onPersistRejected, onRecoveryFailure, peekApplyHandler, persist, persist, persistAll, persistAllAsync, persistAsync, persistAsync, receiveCommand, receiveRecover, recovering, recoveryFinished, recoveryRunning, recoveryStarted, requestRecoveryPermit, setLastSequenceNr, snapshotSequenceNr, snapshotStore, snapshotterId, startRecovery, stashInternally, unhandled, unstashAll, unstashInternally, updateLastSequenceNr, waitingRecoveryPermit
deleteSnapshot, deleteSnapshots, loadSnapshot, saveSnapshot
internalStashOverflowStrategy
actorCell, clearStash, context, enqueueFirst, mailbox, prepend, self, stash, unstash, unstashAll
createStash
recovery