Signal completion of handling a command, without applying any external effects.
Allows for graceful passivation of the replicated entity when used with Cluster Sharding, without the risk of dropping messages that are currently enqueued in its mailbox.
Allows for graceful passivation of the replicated entity when used with Cluster Sharding, without the risk of dropping messages that are currently enqueued in its mailbox.
Using sharding also triggers automatic passivation based on inactivity, see auto-passivate-after
in
reference.conf
for more details.
Passivation is often implemented in order to safely stop the replicated entity,
and free up memory for use for other active entities. This can be done as direct effect
of handling a Command or by defining receive timeout (context.setReceiveTimeout
).
If a message is already enqueued to the entity when it stops itself the enqueued message
in the mailbox will be dropped. Passivation is implemented by notifying the entity's
parent ShardRegion
using a Passivate
message, same as in Cluster Sharding.
The specified wrapped stopMessage
will be sent back to the entity, which is
then supposed to stop itself. Incoming messages will be buffered by the ShardRegion
between reception of Passivate
and termination of the entity. Such buffered messages
are thereafter delivered to a new incarnation of the entity.
If the replicated entity is used without sharding the command is sent to the entity itself directly.
If eventOpt
contains an event, persist it or do nothing if empty.
Has the same behaviour as persist(List(evt1, evt2, evt3))
Has the same behaviour as persist(List(evt1, evt2))
Persist all of a the given events.
Persist all of a the given events. Each event will be applied through applyEffect
separately but not until
all events has been persisted. If an afterCallBack
is added through Effect#andThen that will invoked
after all the events has been persisted.
Persist a single event
Stops the replicated entity after handling the current command.
Stops the replicated entity after handling the current command.
It still is possible to attach andThen
callbacks, to be executed before the entity stops.
Not intended for user extension. Access an instance through ReplicatedEntity#Effect.