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:
UntypedAbstractActorWithTimers
public abstract class UntypedAbstractActor extends AbstractActor
If the validation of theReceiveBuilder
match logic turns out to be a bottleneck for some of your actors you can consider to implement it at lower level by extendingUntypedAbstractActor
instead ofAbstractActor
. The partial functions created by theReceiveBuilder
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 extendingUntypedAbstractActor
each message is received as an untypedObject
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.Receive
-
Nested classes/interfaces inherited from interface org.apache.pekko.actor.Actor
Actor.emptyBehavior$, Actor.ignoringBehavior$
-
-
Constructor Summary
Constructors Constructor Description UntypedAbstractActor()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description AbstractActor.Receive
createReceive()
An actor has to define its initial receive behavior by implementing thecreateReceive
method.abstract void
onReceive(java.lang.Object message)
To be implemented by concrete UntypedAbstractActor, this defines the behavior of the actor.scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit>
receive()
Scala API: This defines the initial actor behavior, it must return a partial function with the actor logic.void
unhandled(java.lang.Object message)
Recommended 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, supervisorStrategy
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.pekko.actor.Actor
aroundPostRestart, aroundPostStop, aroundPreRestart, aroundPreStart, aroundReceive, sender
-
-
-
-
Method Detail
-
createReceive
public final AbstractActor.Receive createReceive()
Description copied from class:AbstractActor
An actor has to define its initial receive behavior by implementing thecreateReceive
method.- Specified by:
createReceive
in classAbstractActor
-
onReceive
public abstract void onReceive(java.lang.Object message) throws java.lang.Throwable
To be implemented by concrete UntypedAbstractActor, this defines the behavior of the actor.- Throws:
java.lang.Throwable
-
receive
public scala.PartialFunction<java.lang.Object,scala.runtime.BoxedUnit> receive()
Description copied from interface:Actor
Scala API: This defines the initial actor behavior, it must return a partial function with the actor logic.- Specified by:
receive
in interfaceActor
- Overrides:
receive
in classAbstractActor
-
unhandled
public void unhandled(java.lang.Object message)
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.Terminated
message) or publishes anpekko.actor.UnhandledMessage
to the actor's system'spekko.event.EventStream
.
-
-