Class Topic$


  • public class Topic$
    extends java.lang.Object
    A pub sub topic is an actor that handles subscribing to a topic and publishing messages to all subscribed actors.

    It is mostly useful in a clustered setting, where it is intended to be started once on every node that want to house subscribers or publish messages to the topic, but it also works in a local setting without cluster.

    In a clustered context messages are deduplicated so that there is at most one message sent to each node for each publish and if there are no subscribers on a node, no message is sent to it. Note that the list of subscribers is eventually consistent and there are no delivery guarantees built in.

    Each topic results in a ServiceKey in the Receptionist so the same scaling recommendation holds for topics, see docs: https://doc.akka.io/docs/akka/current/typed/actor-discovery.html#receptionist-scalability

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Topic$ MODULE$
      Static reference to the singleton instance of this Scala object.
    • Constructor Summary

      Constructors 
      Constructor Description
      Topic$()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T> Behavior<Topic.Command<T>> apply​(java.lang.String topicName, scala.reflect.ClassTag<T> classTag)
      Scala API: Create a topic actor behavior for the given topic name and message type.
      <T> Behavior<Topic.Command<T>> create​(java.lang.Class<T> messageClass, java.lang.String topicName)
      Java API: Create a topic actor behavior for the given topic name and message class
      <T> Topic.Command<T> getTopicStats​(ActorRef<Topic.TopicStats> replyTo)
      Java API: Get a summary of the state for a local topic actor.
      <T> Topic.Command<T> publish​(T message)
      Java API: Publish the message to all currently known subscribers.
      <T> Topic.Command<T> subscribe​(ActorRef<T> subscriber)
      Java API: Subscribe to this topic.
      <T> Topic.Command<T> unsubscribe​(ActorRef<T> subscriber)
      Java API: Unsubscribe a previously subscribed actor from this topic.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • MODULE$

        public static final Topic$ MODULE$
        Static reference to the singleton instance of this Scala object.
    • Constructor Detail

      • Topic$

        public Topic$()
    • Method Detail

      • publish

        public <T> Topic.Command<T> publish​(T message)
        Java API: Publish the message to all currently known subscribers.
      • subscribe

        public <T> Topic.Command<T> subscribe​(ActorRef<T> subscriber)
        Java API: Subscribe to this topic. Should only be used for local subscribers.
      • getTopicStats

        public <T> Topic.Command<T> getTopicStats​(ActorRef<Topic.TopicStats> replyTo)
        Java API: Get a summary of the state for a local topic actor.

        See TopicStats for caveats

      • unsubscribe

        public <T> Topic.Command<T> unsubscribe​(ActorRef<T> subscriber)
        Java API: Unsubscribe a previously subscribed actor from this topic.
      • apply

        public <T> Behavior<Topic.Command<T>> apply​(java.lang.String topicName,
                                                    scala.reflect.ClassTag<T> classTag)
        Scala API: Create a topic actor behavior for the given topic name and message type.
      • create

        public <T> Behavior<Topic.Command<T>> create​(java.lang.Class<T> messageClass,
                                                     java.lang.String topicName)
        Java API: Create a topic actor behavior for the given topic name and message class