Class Receptionist

  • All Implemented Interfaces:
    Extension

    public abstract class Receptionist
    extends java.lang.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 Detail

      • Receptionist

        public Receptionist()
    • Method Detail

      • 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 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 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.

      • 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,
                                                       java.util.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,
                                                       java.util.Set<ActorRef<T>> serviceInstances,
                                                       java.util.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​(java.lang.Object other)