Class Effect$
- java.lang.Object
-
- akka.persistence.typed.scaladsl.Effect$
-
public class Effect$ extends java.lang.Object
Factory methods for creatingEffect
directives - how an event sourced actor reacts on a command.
-
-
Constructor Summary
Constructors Constructor Description Effect$()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <Event,State>
Effect<Event,State>async(scala.concurrent.Future<Effect<Event,State>> effect)
Asynchronous command handling.<Event,State>
ReplyEffect<Event,State>asyncReply(scala.concurrent.Future<ReplyEffect<Event,State>> effect)
Same asEffect.async
when theEventSourcedBehavior
is created withEventSourcedBehavior.withEnforcedReplies
.<Event,State>
EffectBuilder<Event,State>none()
Do not persist anything<Event,State>
ReplyEffect<Event,State>noReply()
WhenEventSourcedBehavior.withEnforcedReplies
is used there will be compilation errors if the returned effect isn't aReplyEffect
.<Event,A extends Event,B extends Event,State>
EffectBuilder<Event,State>persist(A evt1, B evt2, scala.collection.immutable.Seq<Event> events)
Persist multiple events<Event,State>
EffectBuilder<Event,State>persist(Event event)
Persist a single event<Event,State>
EffectBuilder<Event,State>persist(scala.collection.immutable.Seq<Event> events)
Persist multiple events<ReplyMessage,Event,State>
ReplyEffect<Event,State>reply(ActorRef<ReplyMessage> replyTo, ReplyMessage replyWithMessage)
Send a reply message to the command.<Event,State>
ReplyEffect<Event,State>stash()
Stash the current command.<Event,State>
EffectBuilder<Event,State>stop()
Stop this persistent actor Side effects can be chained withthenRun
<Event,State>
EffectBuilder<Event,State>unhandled()
This command is not handled, but it is not an error that it isn't.<Event,State>
Effect<Event,State>unstashAll()
Unstash the commands that were stashed withEffect.stash
.
-
-
-
Field Detail
-
MODULE$
public static final Effect$ MODULE$
Static reference to the singleton instance of this Scala object.
-
-
Method Detail
-
persist
public <Event,State> EffectBuilder<Event,State> persist(Event event)
Persist a single eventSide effects can be chained with
thenRun
-
persist
public <Event,A extends Event,B extends Event,State> EffectBuilder<Event,State> persist(A evt1, B evt2, scala.collection.immutable.Seq<Event> events)
Persist multiple eventsSide effects can be chained with
thenRun
-
persist
public <Event,State> EffectBuilder<Event,State> persist(scala.collection.immutable.Seq<Event> events)
Persist multiple eventsSide effects can be chained with
thenRun
-
none
public <Event,State> EffectBuilder<Event,State> none()
Do not persist anythingSide effects can be chained with
thenRun
-
unhandled
public <Event,State> EffectBuilder<Event,State> unhandled()
This command is not handled, but it is not an error that it isn't.Side effects can be chained with
thenRun
-
stop
public <Event,State> EffectBuilder<Event,State> stop()
Stop this persistent actor Side effects can be chained withthenRun
-
stash
public <Event,State> ReplyEffect<Event,State> stash()
Stash the current command. Can be unstashed later withEffect.unstashAll
.Note that the stashed commands are kept in an in-memory buffer, so in case of a crash they will not be processed. They will also be discarded if the actor is restarted (or stopped) due to that an exception was thrown from processing a command or side effect after persisting. The stash buffer is preserved for persist failures if a backoff supervisor strategy is defined with
EventSourcedBehavior.onPersistFailure
.Side effects can be chained with
thenRun
-
unstashAll
public <Event,State> Effect<Event,State> unstashAll()
Unstash the commands that were stashed withEffect.stash
.It's allowed to stash messages while unstashing. Those newly added commands will not be processed by this
unstashAll
effect and have to be unstashed by anotherunstashAll
.- See Also:
EffectBuilder.thenUnstashAll
-
reply
public <ReplyMessage,Event,State> ReplyEffect<Event,State> reply(ActorRef<ReplyMessage> replyTo, ReplyMessage replyWithMessage)
Send a reply message to the command. The type of the reply message must conform to the type specified by the passed replyToActorRef
.This has the same semantics as
cmd.replyTo.tell
.It is provided as a convenience (reducing boilerplate) and a way to enforce that replies are not forgotten when the
EventSourcedBehavior
is created withEventSourcedBehavior.withEnforcedReplies
. WhenwithEnforcedReplies
is used there will be compilation errors if the returned effect isn't aReplyEffect
. The reply message will be sent also ifwithEnforcedReplies
isn't used, but then the compiler will not help finding mistakes.
-
noReply
public <Event,State> ReplyEffect<Event,State> noReply()
WhenEventSourcedBehavior.withEnforcedReplies
is used there will be compilation errors if the returned effect isn't aReplyEffect
. ThisnoReply
can be used as a conscious decision that a reply shouldn't be sent for a specific command or the reply will be sent later.
-
async
public <Event,State> Effect<Event,State> async(scala.concurrent.Future<Effect<Event,State>> effect)
Asynchronous command handling. The effect is run when theFuture
has been completed. Any incoming commands are stashed and processed later, after current command, when theFuture
has been completed.This can for example be used for retrieval of external information before validating the command.
-
asyncReply
public <Event,State> ReplyEffect<Event,State> asyncReply(scala.concurrent.Future<ReplyEffect<Event,State>> effect)
Same asEffect.async
when theEventSourcedBehavior
is created withEventSourcedBehavior.withEnforcedReplies
.
-
-