public class EffectFactories<Command,Event,State>
extends java.lang.Object
| 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 with a list containing [evt1, evt2] |
<A extends Event,B extends Event,C extends Event> |
persist(A evt1,
B evt2,
C evt3)
Has the same behaviour as
persist with a list containing [evt1, evt2, evt3] |
Effect<Event,State> |
persist(Event event)
Persist a single event
|
Effect<Event,State> |
persist(java.util.List<Event> events)
Persist all of a the given events.
|
Effect<Event,State> |
persist(java.util.Optional<Event> eventOpt)
If
eventOpt contains an event persist it, if it is empty do nothing (none()). |
Effect<Event,State> |
stop()
Stops the replicated entity after handling the current command.
|
Effect<Event,State> |
unhandled()
Do-nothing but mark command as unhandled, this will lead to command being passed to the regular
Actor.unhandled(java.lang.Object) logic being invoked for the command. |
public final 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 final Effect<Event,State> persist(Event event)
event - (undocumented)public final Effect<Event,State> persist(java.util.List<Event> events)
applyEffect separately but not until
all events has been persisted. If an afterCallBack is added through Effect.andThen(java.util.function.Consumer<State>) that will invoked
after all the events has been persisted.events - (undocumented)public Effect<Event,State> persist(java.util.Optional<Event> eventOpt)
eventOpt contains an event persist it, if it is empty do nothing (none()).eventOpt - (undocumented)public final <A extends Event,B extends Event> Effect<Event,State> persist(A evt1, B evt2)
persist with a list containing [evt1, evt2]evt1 - (undocumented)evt2 - (undocumented)public final <A extends Event,B extends Event,C extends Event> Effect<Event,State> persist(A evt1, B evt2, C evt3)
persist with a list containing [evt1, evt2, evt3]evt1 - (undocumented)evt2 - (undocumented)evt3 - (undocumented)public final Effect<Event,State> stop()
andThen callbacks, to be executed before the entity stops.