Immutable behavior that exposes additional fluent DSL methods to further change the message or signal reception behavior.
Immutable behavior that exposes additional fluent DSL methods to further change the message or signal reception behavior.
A behavior that treats every incoming message as unhandled.
A behavior that ignores every incoming message and returns “same”.
Behavior decorator that copies all received message to the designated monitor akka.actor.typed.ActorRef before invoking the wrapped behavior.
Behavior decorator that copies all received message to the designated
monitor akka.actor.typed.ActorRef before invoking the wrapped behavior. The
wrapped behavior can evolve (i.e. return different behavior) without needing to be
wrapped in a monitor
call again.
Construct an actor behavior that can react to both incoming messages and lifecycle signals.
Construct an actor behavior that can react to both incoming messages and lifecycle signals. After spawning this actor from another actor (or as the guardian of an akka.actor.typed.ActorSystem) it will be executed within an ActorContext that allows access to the system, spawning and watching other actors, etc.
This constructor is called immutable because the behavior instance does not need and in fact should not use (close over) mutable variables, but instead return a potentially different behavior encapsulating any state changes.
Simplified version of Receive with only a single argument - the message to be handled.
Simplified version of Receive with only a single argument - the message to be handled. Useful for when the context is already accessible by other means, like being wrapped in an setup or similar.
Construct an actor behavior that can react to both incoming messages and lifecycle signals. After spawning this actor from another actor (or as the guardian of an akka.actor.typed.ActorSystem) it will be executed within an ActorContext that allows access to the system, spawning and watching other actors, etc.
This constructor is called immutable because the behavior instance does not need and in fact should not use (close over) mutable variables, but instead return a potentially different behavior encapsulating any state changes.
Construct an immutable actor behavior from a partial message handler which treats undefined messages as unhandled.
Construct an immutable actor behavior from a partial message handler which treats undefined messages as unhandled.
Behaviors can also be composed with Behavior#orElse.
Construct an immutable actor behavior from a partial message handler which treats undefined messages as unhandled.
Construct an immutable actor behavior from a partial message handler which treats undefined messages as unhandled.
Behaviors can also be composed with Behavior#orElse.
Construct an actor behavior that can react to lifecycle signals only.
Return this behavior from message processing in order to advise the system to reuse the previous behavior.
Return this behavior from message processing in order to advise the system to reuse the previous behavior. This is provided in order to avoid the allocation overhead of recreating the current behavior where that is not necessary.
setup
is a factory for a behavior.
setup
is a factory for a behavior. Creation of the behavior instance is deferred until
the actor is started, as opposed to Behaviors.receive that creates the behavior instance
immediately before the actor is running. The factory
function pass the ActorContext
as parameter and that can for example be used for spawning child actors.
setup
is typically used as the outer most behavior when spawning an actor, but it
can also be returned as the next behavior when processing a message or signal. In that
case it will be started immediately after it is returned, i.e. next message will be
processed by the started behavior.
Return this behavior from message processing to signal that this actor shall terminate voluntarily.
Return this behavior from message processing to signal that this actor shall terminate voluntarily. If this actor has created child actors then these will be stopped as part of the shutdown procedure.
The PostStop signal that results from stopping this actor will be passed to the
given postStop
behavior. All other messages and signals will effectively be
ignored.
Return this behavior from message processing to signal that this actor shall terminate voluntarily.
Return this behavior from message processing to signal that this actor shall terminate voluntarily. If this actor has created child actors then these will be stopped as part of the shutdown procedure.
The PostStop signal that results from stopping this actor will be passed to the current behavior. All other messages and signals will effectively be ignored.
Wrap the given behavior with the given SupervisorStrategy for the given exception.
Wrap the given behavior with the given SupervisorStrategy for
the given exception.
Exceptions that are not subtypes of Thr
will not be
caught and thus lead to the termination of the actor.
It is possible to specify different supervisor strategies, such as restart, resume, backoff.
Note that only scala.util.control.NonFatal throwables will trigger the supervision strategy.
Example:
val dbConnector: Behavior[DbCommand] = ... val dbRestarts = Behaviors.supervise(dbConnector) .onFailure(SupervisorStrategy.restart) // handle all NonFatal exceptions val dbSpecificResumes = Behaviors.supervise(dbConnector) .onFailure[IndexOutOfBoundsException](SupervisorStrategy.resume) // resume for IndexOutOfBoundsException exceptions
This type of Behavior wraps another Behavior while allowing you to perform some action upon each received message or signal.
This type of Behavior wraps another Behavior while allowing you to perform some action upon each received message or signal. It is most commonly used for logging or tracing what a certain Actor does.
Return this behavior from message processing in order to advise the system to reuse the previous behavior, including the hint that the message has not been handled.
Return this behavior from message processing in order to advise the system to reuse the previous behavior, including the hint that the message has not been handled. This hint may be used by composite behaviors that delegate (partial) handling to other behaviors.
Combination of static and per message MDC (Mapped Diagnostic Context).
Combination of static and per message MDC (Mapped Diagnostic Context).
Each message will get the static MDC plus the MDC returned for the message. If the same key are in both the static and the per message MDC the per message one overwrites the static one in the resulting log entries.
The staticMdc
or mdcForMessage
may be empty.
A static MDC applied for each message
Is invoked before each message is handled, allowing to setup MDC, MDC is cleared after each message processing by the inner behavior is done.
The actual behavior handling the messages, the MDC is used for the log entries logged through
ActorContext.log
See also akka.actor.typed.Logger.withMdc
Static MDC (Mapped Diagnostic Context)
Static MDC (Mapped Diagnostic Context)
This MDC is setup in the logging context for every message
The actual behavior handling the messages, the MDC is used for the log entries logged through
ActorContext.log
See also akka.actor.typed.Logger.withMdc
Per message MDC (Mapped Diagnostic Context) logging.
Per message MDC (Mapped Diagnostic Context) logging.
Is invoked before each message is handled, allowing to setup MDC, MDC is cleared after each message processing by the inner behavior is done.
The actual behavior handling the messages, the MDC is used for the log entries logged through
ActorContext.log
See also akka.actor.typed.Logger.withMdc
Support for scheduled self
messages in an actor.
Support for scheduled self
messages in an actor.
It takes care of the lifecycle of the timers such as cancelling them when the actor
is restarted or stopped.
This type of Behavior wraps another Behavior while allowing you to perform some action upon each received message or signal.
This type of Behavior wraps another Behavior while allowing you to perform some action upon each received message or signal. It is most commonly used for logging or tracing what a certain Actor does.
(Since version 2.5.13) Use overloaded tap
Factories for akka.actor.typed.Behavior.