Class Dispatcher

All Implemented Interfaces:
Executor, BatchingExecutor, scala.concurrent.ExecutionContext, scala.concurrent.ExecutionContextExecutor
Direct Known Subclasses:
PinnedDispatcher

public class Dispatcher extends MessageDispatcher
The event-based Dispatcher binds a set of Actors to a thread pool backed up by a BlockingQueue.

The preferred way of creating dispatchers is to define configuration of it and use the the lookup method in pekko.dispatch.Dispatchers.

param: throughput positive integer indicates the dispatcher will only process so much messages at a time from the mailbox, without checking the mailboxes of other actors. Zero or negative means the dispatcher always continues until the mailbox is empty. Larger values (or zero or negative) increase throughput, smaller values increase fairness

  • Constructor Details

  • Method Details

    • batchable

      public final boolean batchable(Runnable runnable)
      Description copied from interface: BatchingExecutor
      Override this to define which runnables will be batched.
    • createMailbox

      protected org.apache.pekko.dispatch.Mailbox createMailbox(Cell actor, MailboxType mailboxType)
      INTERNAL API
      Specified by:
      createMailbox in class MessageDispatcher
    • dispatch

      protected void dispatch(org.apache.pekko.actor.ActorCell receiver, Envelope invocation)
      INTERNAL API

      Opentelemetry Java Instrumentation relies on this method so avoid changing it. The agent attaches the context that is current at send time to the Envelope here, and ActorCell.invoke makes it current again while the message is handled. See https://github.com/apache/pekko/issues/3472

      Specified by:
      dispatch in class MessageDispatcher
    • executeTask

      protected void executeTask(TaskInvocation invocation)
      INTERNAL API
      Specified by:
      executeTask in class MessageDispatcher
    • executorService

      protected final ExecutorServiceDelegate executorService()
    • id

      public String id()
      Description copied from class: MessageDispatcher
      Identifier of this dispatcher, corresponds to the full key of the dispatcher configuration.
      Specified by:
      id in class MessageDispatcher
    • registerForExecution

      protected boolean registerForExecution(org.apache.pekko.dispatch.Mailbox mbox, boolean hasMessageHint, boolean hasSystemMessageHint)
      Returns if it was registered

      INTERNAL API

      Specified by:
      registerForExecution in class MessageDispatcher
    • shutdown

      protected void shutdown()
      INTERNAL API
      Specified by:
      shutdown in class MessageDispatcher
    • shutdownTimeout

      public scala.concurrent.duration.FiniteDuration shutdownTimeout()
      Description copied from class: MessageDispatcher
      When the dispatcher no longer has any actors registered, how long will it wait until it shuts itself down, defaulting to your pekko configs "pekko.actor.default-dispatcher.shutdown-timeout" or default specified in reference.conf

      INTERNAL API

      Specified by:
      shutdownTimeout in class MessageDispatcher
    • systemDispatch

      protected void systemDispatch(org.apache.pekko.actor.ActorCell receiver, SystemMessage invocation)
      INTERNAL API
      Specified by:
      systemDispatch in class MessageDispatcher
    • throughput

      public int throughput()
      Description copied from class: MessageDispatcher
      INTERNAL API
      Specified by:
      throughput in class MessageDispatcher
    • throughputDeadlineTime

      public scala.concurrent.duration.Duration throughputDeadlineTime()
      Description copied from class: MessageDispatcher
      INTERNAL API
      Specified by:
      throughputDeadlineTime in class MessageDispatcher
    • toString

      public String toString()
      Overrides:
      toString in class Object