Package org.apache.pekko.actor
Class UntypedAbstractActor
java.lang.Object
org.apache.pekko.actor.AbstractActor
org.apache.pekko.actor.UntypedAbstractActor
- All Implemented Interfaces:
Actor
- Direct Known Subclasses:
UntypedAbstractActorWithStash,UntypedAbstractActorWithTimers,UntypedAbstractActorWithUnboundedStash,UntypedAbstractActorWithUnrestrictedStash,UntypedAbstractLoggingActor
If the validation of the
ReceiveBuilder match logic turns out to be a bottleneck for some of your
actors you can consider to implement it at lower level by extending UntypedAbstractActor instead
of AbstractActor. The partial functions created by the ReceiveBuilder consist of multiple lambda
expressions for every match statement, where each lambda is referencing the code to be run. This is something
that the JVM can have problems optimizing and the resulting code might not be as performant as the
untyped version. When extending UntypedAbstractActor each message is received as an untyped
Object and you have to inspect and cast it to the actual message type in other ways (instanceof checks).-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.pekko.actor.AbstractActor
AbstractActor.ActorContext, AbstractActor.ReceiveNested classes/interfaces inherited from interface org.apache.pekko.actor.Actor
Actor.emptyBehavior$, Actor.ignoringBehavior$ -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal AbstractActor.ReceiveAn actor has to define its initial receive behavior by implementing thecreateReceivemethod.abstract voidTo be implemented by concrete UntypedAbstractActor, this defines the behavior of the actor.scala.PartialFunction<Object,scala.runtime.BoxedUnit> receive()Scala API: This defines the initial actor behavior, it must return a partial function with the actor logic.voidRecommended convention is to call this method if the message isn't handled inonReceive(java.lang.Object)(e.g.Methods inherited from class org.apache.pekko.actor.AbstractActor
context, emptyBehavior, getContext, getSelf, getSender, org$apache$pekko$actor$Actor$_setter_$context_$eq, org$apache$pekko$actor$Actor$_setter_$self_$eq, postRestart, postStop, preRestart, preRestart, preStart, receiveBuilder, self, supervisorStrategyMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.pekko.actor.Actor
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, sender
-
Constructor Details
-
UntypedAbstractActor
public UntypedAbstractActor()
-
-
Method Details
-
createReceive
Description copied from class:AbstractActorAn actor has to define its initial receive behavior by implementing thecreateReceivemethod.- Specified by:
createReceivein classAbstractActor
-
onReceive
To be implemented by concrete UntypedAbstractActor, this defines the behavior of the actor.- Throws:
Throwable
-
receive
Description copied from interface:ActorScala API: This defines the initial actor behavior, it must return a partial function with the actor logic.- Specified by:
receivein interfaceActor- Overrides:
receivein classAbstractActor
-
unhandled
Recommended convention is to call this method if the message isn't handled inonReceive(java.lang.Object)(e.g. unknown message type). By default it fails with either apekko.actor.DeathPactException(in case of an unhandledpekko.actor.Terminatedmessage) or publishes anpekko.actor.UnhandledMessageto the actor's system'spekko.event.EventStream.
-