SingletonCluster Actor not getting intialized properly (Unable to send messages / register with receptionist)

problem:

I’m creating a cluster singleton actor, but

  1. the actor doesn’t seem to be getting created ?
  2. when i try to register it with the receptionist, it doesn’t get
    registered.
  3. 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 ?

Did you join the cluster?

1 Like

Hi, your suspicion was correct.

I had not joined the cluster. I was trying to run the program as a single cluster, but didn’t do it the correct way.