ClusterSharding: How to stop all the actors in a cluster shard?

I am working with Akka and have used ClusterSharding for a usecase. For some reason I want to stop all the actors in the ClusterShard.

Can somene help me with a way of doing it?

You could use Distributed Pub Sub to send a stop message to all actors subscribing to a topic. You can define topics to be 1:1 to the shards.

Hey Thanks Patrik, a question though, wont the cluster shard restart them? In my understanding I will have to passivate them.

That ”stop” message can be (must be) a message they understand and when receiving they can passivate. However, unless you use remember entities they could just stop themselves in this case. They would only be started when next message arrives.