problem:
I’m creating a cluster singleton actor, but
- the actor doesn’t seem to be getting created ?
- when i try to register it with the receptionist, it doesn’t get
registered. - when i try to send a message to it - it doesn’t get
sent (meaning, when i do a .tell(msg) on this actor, the handling behavior does not get triggered)
Here is what my actor class looks like
public class QueryExecutorActor extends AbstractBehavior<QueryExecutorActor.Command> {
public static ServiceKey<Command> key = ServiceKey.create(Command.class, "QueryExecutor");
private final Config config;
private QueryExecutorActor(ActorContext<Command> context, Config config) {
super(context);
this.config = config;
context.getSystem().receptionist().tell(Receptionist.register(key, context.getSelf()));
log.info("created")
}
public static Behavior<Command> create(Config config) {
return Behaviors.setup(context -> new QueryExecutorActor(context, config));
}
As you can see, I am telling the receptionist to register this actor, and also printing a log statement - neither of which takes place when the create()
function is called.
ClusterSingleton singleton = ClusterSingleton.get(system)
ActorRef<QueryExecutor.Command> queryExecutorRef = singleton.init(SingletonActor.of(QueryExecutor.create(config), QueryExecutor.key.id()));
log.info("Started on", queryExecutorRef.path()); // prints akka://app/system/singletonProxyQueryExecutor-no-dc
Here, it “looks” like the actor is created, since i am able to get its path - but how come none of that stuff in the constructor gets ever logged or register itself with the receptionist ?