Class Router

java.lang.Object
org.apache.pekko.routing.Router
All Implemented Interfaces:
Serializable, scala.Equals, scala.Product

public final class Router extends Object implements scala.Product, Serializable
For each message that is sent through the router via the route(java.lang.Object, org.apache.pekko.actor.ActorRef) method the RoutingLogic decides to which Routee to send the message. The Routee itself knows how to perform the actual sending. Normally the RoutingLogic picks one of the contained routees, but that is up to the implementation of the RoutingLogic.

A Router is immutable and the RoutingLogic must be thread safe.

See Also:
  • Constructor Details

  • Method Details

    • $lessinit$greater$default$2

      public static scala.collection.immutable.IndexedSeq<Routee> $lessinit$greater$default$2()
    • apply

      public static Router apply(RoutingLogic logic, scala.collection.immutable.IndexedSeq<Routee> routees)
    • apply$default$2

      public static scala.collection.immutable.IndexedSeq<Routee> apply$default$2()
    • unapply

      public static scala.Option<scala.Tuple2<RoutingLogic,scala.collection.immutable.IndexedSeq<Routee>>> unapply(Router x$0)
    • logic

      public RoutingLogic logic()
    • routees

      public scala.collection.immutable.IndexedSeq<Routee> routees()
    • route

      public void route(Object message, ActorRef sender)
      Send the message to the destination Routee selected by the RoutingLogic. If the message is a pekko.routing.RouterEnvelope it will be unwrapped before sent to the destinations. Messages wrapped in a Broadcast envelope are always sent to all routees.
    • withRoutees

      public Router withRoutees(scala.collection.immutable.IndexedSeq<Routee> rs)
      Create a new instance with the specified routees and the same RoutingLogic.
    • addRoutee

      public Router addRoutee(Routee routee)
      Create a new instance with one more routee and the same RoutingLogic.
    • addRoutee

      public Router addRoutee(ActorRef ref)
      Create a new instance with one more ActorRefRoutee for the specified pekko.actor.ActorRef and the same RoutingLogic.
    • addRoutee

      public Router addRoutee(ActorSelection sel)
      Create a new instance with one more ActorSelectionRoutee for the specified pekko.actor.ActorSelection and the same RoutingLogic.
    • removeRoutee

      public Router removeRoutee(Routee routee)
      Create a new instance without the specified routee.
    • removeRoutee

      public Router removeRoutee(ActorRef ref)
      Create a new instance without the ActorRefRoutee for the specified pekko.actor.ActorRef.
    • removeRoutee

      public Router removeRoutee(ActorSelection sel)
      Create a new instance without the ActorSelectionRoutee for the specified pekko.actor.ActorSelection.
    • copy

      public Router copy(RoutingLogic logic, scala.collection.immutable.IndexedSeq<Routee> routees)
    • copy$default$1

      public RoutingLogic copy$default$1()
    • copy$default$2

      public scala.collection.immutable.IndexedSeq<Routee> copy$default$2()
    • productPrefix

      public String productPrefix()
      Specified by:
      productPrefix in interface scala.Product
    • productArity

      public int productArity()
      Specified by:
      productArity in interface scala.Product
    • productElement

      public Object productElement(int x$1)
      Specified by:
      productElement in interface scala.Product
    • productIterator

      public scala.collection.Iterator<Object> productIterator()
      Specified by:
      productIterator in interface scala.Product
    • canEqual

      public boolean canEqual(Object x$1)
      Specified by:
      canEqual in interface scala.Equals
    • productElementName

      public String productElementName(int x$1)
      Specified by:
      productElementName in interface scala.Product
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object x$1)
      Specified by:
      equals in interface scala.Equals
      Overrides:
      equals in class Object