We are using event sourcing with Akka Persistence by extending EventSourcedBehavior. When we create the persistent actor we give it an unique name, by using an uuid (the same we use inside
create to build the
PersistenceId, for entity sharding):
UUID uuid = UUID.randomUUID(); String name = MyBehavior.nameFor(uuid); ActorRef<Command> actorRef = context.spawn(MyBehavior.create(uuid), name);
Later on, when we want to send further commands to the actor, we would like to get an
ActorRef<Command> from the context, since the
actorRef object reference returned by
spawn won’t be in scope anymore. Think about commands as a result of subsequents HTTP requests.
We can’t use
context.getChild(name) as it returns
We’ve also considered actor discovery with Receptionist, but the documentation says it doesn’t scale to any number of actors:
On the other hand, ActorSelection is not supported in typed, as per the following link:
We are not sure about the right approach here. Any help would be much appreciated.