Class Receptionist

java.lang.Object
org.apache.pekko.actor.typed.receptionist.Receptionist
All Implemented Interfaces:
Extension

public abstract class Receptionist extends Object implements Extension
Register and discover actors that implement a service with a protocol defined by a ServiceKey.

This class is not intended for user extension other than for test purposes (e.g. stub implementation). More methods may be added in the future and that may break such implementations.

  • Constructor Details

    • Receptionist

      public Receptionist()
  • Method Details

    • createExtension

      public static Receptionist createExtension(ActorSystem<?> system)
    • get

      public static Receptionist get(ActorSystem<?> system)
    • register

      public static <T> Receptionist.Command register(ServiceKey<T> key, ActorRef<T> service)
      Java API: A Register message without Ack that the service was registered. Associate the given pekko.actor.typed.ActorRef with the given ServiceKey by sending this command to the Receptionist.ref.

      Multiple registrations can be made for the same key. De-registration is implied by the end of the referenced Actor&rsquo;s lifecycle, but it can also be explicitly deregistered before termination.

    • register

      public static <T> Receptionist.Command register(ServiceKey<T> key, ActorRef<T> service, ActorRef<Receptionist.Registered> replyTo)
      Java API: A Register message with Ack that the service was registered. Associate the given pekko.actor.typed.ActorRef with the given ServiceKey by sending this command to the Receptionist.ref.

      Multiple registrations can be made for the same key. De-registration is implied by the end of the referenced Actor&rsquo;s lifecycle, but it can also be explicitly deregistered before termination.

      Registration will be acknowledged with the Receptionist.Registered message to the given replyTo actor.

    • registered

      public static <T> Receptionist.Registered registered(ServiceKey<T> key, ActorRef<T> serviceInstance)
      Java API: Sent by the receptionist, available here for easier testing
    • deregister

      public static <T> Receptionist.Command deregister(ServiceKey<T> key, ActorRef<T> service)
      Java API: A Deregister message without Ack that the service was unregistered
    • deregister

      public static <T> Receptionist.Command deregister(ServiceKey<T> key, ActorRef<T> service, ActorRef<Receptionist.Deregistered> replyTo)
      Java API: A Deregister message with an actor that will get an ack that the service was unregistered
    • deregistered

      public static <T> Receptionist.Deregistered deregistered(ServiceKey<T> key, ActorRef<T> serviceInstance)
      Java API: Sent by the receptionist, available here for easier testing
    • subscribe

      public static <T> Receptionist.Command subscribe(ServiceKey<T> key, ActorRef<Receptionist.Listing> subscriber)
      Java API: Subscribe message. The given actor to service updates when this command is sent to the Receptionist.ref. When the set of instances registered for the given key changes the subscriber will be sent a Receptionist.Listing with the new set of instances for that service.

      The subscription will be acknowledged by sending out a first Receptionist.Listing. The subscription automatically ends with the termination of the subscriber.

    • find

      public static <T> Receptionist.Command find(ServiceKey<T> key, ActorRef<Receptionist.Listing> replyTo)
      Java API: Find message. Query the Receptionist for a list of all Actors implementing the given protocol at one point in time by sending this command to the Receptionist.ref.
    • listing

      public static <T> Receptionist.Listing listing(ServiceKey<T> key, Set<ActorRef<T>> serviceInstances)
      Java API: Sent by the receptionist, available here for easier testing
    • listing

      public static <T> Receptionist.Listing listing(ServiceKey<T> key, Set<ActorRef<T>> serviceInstances, Set<ActorRef<T>> allServiceInstances, boolean servicesWereAddedOrRemoved)
      Java API: Sent by the receptionist, available here for easier testing
    • apply

      public static final T apply(ActorSystem<?> system)
    • hashCode

      public static final int hashCode()
    • equals

      public static final boolean equals(Object other)
    • id

      public static ExtensionId<T> id()
    • ref

      public abstract ActorRef<Receptionist.Command> ref()