4
votes

Can there be multiple different actors which are singletons in an Akka cluster?

For example, let's say I need a single entry point into multiple systems. I might want Singleton1 to be responsible for entry into System1 and Singleton2 to be responsible for entry into System2. It does not seem ideal to have a single singleton Actor with multiple responsibilities. I'm of course ok with both singleton actors running on the same node.

The Akka docs state the ClusterSingletonManager "manages one singleton actor instance among all cluster nodes or a group of nodes." This, along with the Configuration documentation example, lead me to conclude what I'm asking for is not possible, but I figured I'd ask to confirm. Thanks!

1
Akka docs says 'Using a singleton should not be the first design choice. It has several drawbacks, such as single-point of bottleneck. Single-point of failure is also a relevant concern, but for some cases this feature takes care of that by making sure that another singleton instance will eventually be started.' ClusterReceptionist Instead of singleton? you can manage differents roles to the entry points to the clustergaston

1 Answers

2
votes

This question was answered here in the Akka user list.

You can create many different ClusterSingletonManager actors with different settings, each one managing one singleton.

It's the name of the actor (the second parameter to actorOf) that distinguishes them.

Normally you don't need different configuration in config file. You can use the ClusterSingletonManagerSettings if there is some small differences, such as the role. It's also possible to load ClusterSingletonManagerSettings from a config file section, but that is often not needed.

http://doc.akka.io/docs/akka/current/java/cluster-singleton.html

http://doc.akka.io/japi/akka/2.4/akka/cluster/singleton/ClusterSingletonManager.html