Reputation: 1901
I'd like to have several Actors (which represent a TCP-Connection based on the Akka IO part). These Actors shall update a common model (in memory). This model is kept within a further Actor that manages this model.
My question is, how do I setup this structure? Is there a way to tell akka that there is only one instance of a certain actor?
The alternative would be the following: I already have an actor that takes new TCP/IP connections and passes them to new actors. Now I could create this "Model-Manager-Actor" in the Connection-Receiver and pass this actor to the newly created Per-Connection Actors. But this seems to be not a good way in my point of view because it ties the Model-Manager to the Connection-Receiver.
Does someone know an appropriate solution for this scenario?
Thanks
Upvotes: 0
Views: 160
Reputation: 15472
The simple and direct solution is to create your singleton up front (e.g. when starting the application) and pass its ActorRef to the TCP connection actors when creating them (presumably via the server socket handler actor).
Upvotes: 2