public class EffectFactories<Command,Event,State>
extends java.lang.Object
ReplicatedEntity.Effect().| Constructor and Description |
|---|
EffectFactories() |
| Modifier and Type | Method and Description |
|---|---|
Effect<Event,State> |
none()
Signal completion of handling a command, without applying any external effects.
|
Effect<Event,State> |
passivate(Command msg)
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.
|
<A extends Event,B extends Event> |
persist(A evt1,
B evt2)
Has the same behaviour as
persist(List(evt1, evt2)) |
<A extends Event,B extends Event,C extends Event> |
persist(A evt1,
B evt2,
C evt3)
Has the same behaviour as
persist(List(evt1, evt2, evt3)) |
Effect<Event,State> |
persist(Event event)
Persist a single event
|
Effect<Event,State> |
persist(scala.Option<Event> eventOpt)
If
eventOpt contains an event, persist it or do nothing if empty. |
Effect<Event,State> |
persist(scala.collection.immutable.Seq<Event> events)
Persist all of a the given events.
|
Effect<Event,State> |
stop()
Stops the replicated entity after handling the current command.
|
Effect<Event,State> |
unhandled() |
public Effect<Event,State> none()
public Effect<Event,State> passivate(Command msg)
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.
msg - (undocumented)public Effect<Event,State> persist(Event event)
event - (undocumented)public Effect<Event,State> persist(scala.collection.immutable.Seq<Event> events)
applyEffect separately but not until
all events has been persisted. If an afterCallBack is added through Effect.andThen(scala.Function1<State, scala.runtime.BoxedUnit>) that will invoked
after all the events has been persisted.events - (undocumented)public <A extends Event,B extends Event> Effect<Event,State> persist(A evt1, B evt2)
persist(List(evt1, evt2))evt1 - (undocumented)evt2 - (undocumented)public <A extends Event,B extends Event,C extends Event> Effect<Event,State> persist(A evt1, B evt2, C evt3)
persist(List(evt1, evt2, evt3))evt1 - (undocumented)evt2 - (undocumented)evt3 - (undocumented)public Effect<Event,State> persist(scala.Option<Event> eventOpt)
eventOpt contains an event, persist it or do nothing if empty.eventOpt - (undocumented)public Effect<Event,State> stop()
andThen callbacks, to be executed before the entity stops.