In this moment I have this actor session management implementation running in only one node:
1) I have a SessionManager
actor that handles all sessions
2) The SessionManagerActor
receives two messages: CreateSesion(id)
and ValidateSesion(id)
3) When the SessionManagerActor
receives CreateSesion(id)
message, it creates a SessionActor
using actorFor
method like so:
context.actorOf(Props(new SesionActor(expirationTime)), id)
4) When the SessionManagerActor
receives ValidateSesion(id)
message it looks for an existing SessionActor
and evaluates if exists using resolveOne
method like so:
context.actorSelection("akka://system/user/sessionManager/" + id).resolveOne()
With that logic works nice but I need to implement the same behavior in multiple nodes (cluster)
My question is, which method is recommended to implement that session management behavior so that it works in one or múltiple nodes?
I've read akka documentation and it provides akka-remote
, akka-cluster
, akka-cluster-sharding
, akka-cluster-singleton
, akka-distributed-publish-subscribe-cluster
but I'm not sure about which one is the appropriate and the simplest way to do it. (Note that SessionActors are stateless and I need to locate them anywhere in the cluster.)