Class Topic
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 pekko.actor.typed.receptionist.ServiceKey in the pekko.actor.typed.receptionist.Receptionist
so the same scaling recommendation holds for topics, see docs:
https://pekko.apache.org/docs/pekko/current/typed/actor-discovery.html#receptionist-scalability
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceNot for user extensionstatic classScala API: Get a summary of the state for a local topic actor.static classScala API: Publish the message to all currently known subscribers.static classScala API: Subscribe to this topic.static interfaceResponse to theGetTopicStatsquery.static classScala API: Unsubscribe a previously subscribed actor from this topic. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> Behavior<Topic.Command<T>>Scala API: Create a topic actor behavior for the given topic name and message type.static <T> Behavior<Topic.Command<T>>Java API: Create a topic actor behavior for the given topic name and message classstatic <T> Topic.Command<T>getTopicStats(ActorRef<Topic.TopicStats> replyTo) Java API: Get a summary of the state for a local topic actor.static <T> Topic.Command<T>publish(T message) Java API: Publish the message to all currently known subscribers.static <T> Topic.Command<T>Java API: Subscribe to this topic.static <T> Topic.Command<T>unsubscribe(ActorRef<T> subscriber) Java API: Unsubscribe a previously subscribed actor from this topic.
-
Constructor Details
-
Topic
public Topic()
-
-
Method Details
-
publish
Java API: Publish the message to all currently known subscribers. -
subscribe
Java API: Subscribe to this topic. Should only be used for local subscribers. -
getTopicStats
Java API: Get a summary of the state for a local topic actor.See
Topic.TopicStatsfor caveats -
unsubscribe
Java API: Unsubscribe a previously subscribed actor from this topic. -
apply
public static <T> Behavior<Topic.Command<T>> apply(String topicName, scala.reflect.ClassTag<T> classTag) Scala API: Create a topic actor behavior for the given topic name and message type. -
create
Java API: Create a topic actor behavior for the given topic name and message class
-