Akka - When a topic actor has no subscribers

Viewed 36

I have created one actor that subscribes to one topic to get messages. This is the only actor that subscribes to this topic.

I wondered what will happen if for some reason the actor will unsubscribe and then subscribe again to the same topic (if actor restarts, for example).

From Akka types API documentation (https://doc.akka.io/docs/akka/2.6.19//typed/distributed-pub-sub.html):

When a topic actor has no subscribers for a topic it will deregister itself from the receptionist meaning published messages for the topic will not be sent to it.

What does it means? Does it mean that after restart - no one can send messages to this actor through this topic?

1 Answers

If the only actor subscribing to a topic unsubscribes, messages sent to that topic will no longer be delivered. When that topic has a subscriber again, messages sent after that point may be delivered (messages sent between the subscriptions will not be delivered).

So if you have an actor which is subscribing to a Distributed Pub Sub topic, it should resubscribe on every restart.

Related