Class WorkerActor

java.lang.Object
net.sodacan.core.actor.AbstractActor
net.sodacan.core.actor.WorkerActor
All Implemented Interfaces:
Actor
Direct Known Subclasses:
Sleeper

public abstract class WorkerActor extends AbstractActor

A WorkerActor has no state, it's ephemeral. As such, this kind of actor is more lightweight than many other kinds of actors. A WorkerActor is appropriate to use when parallelism is more important than serialization of messages.

A worker actor usually has a lifecycle of just one message. A WorkerActor usually appears in the same ActorGroup of the Actor that will receive the reply message it will send at the conclusion of the sleep.

Say an Actor needs to be awakened after a few seconds because it is waiting for another message to arrive. Putting a sleep into the Actor would prevent it from receiving any other messages. To solve this problem, the Actor can send a Message to a Sleeper actor, a kind of WorkerActor, that will send a message back to our actor after a delay.

  • Constructor Details

    • WorkerActor

      public WorkerActor(Config config, ActorId actorId)