How to start queue processing after cluster is formed


In my app, I need to tell a QueueProcessor actor to start processing queue events after the cluster is formed and processing result will be sent to persistent actors. At the moment, I start queue processing after the following code, which I think it is not appropriate:

// Akka Management hosts the HTTP routes used by bootstrap

// Starting the bootstrap process needs to be done explicitly

I am thinking two possible ways:

  • ClusterBootstrap(system).start() returns a Future telling the result of bootstrap, but this is not offered.
  • Listening to cluster formed event, which I don’t know which one I should listen to? Shall I listen to ClusterEvent.LeaderChanged and judge based on whether leader is empty or not?

Please help me out. Thanks.


Could you use a Start message to tell the actor to begin processing of the queue? The message shouldn’t be delivered to the actor before the system is ready.

Or you could use Become/Unbecome, perhaps via similar mechanism (a message).

The registerOnMemberUp callback mechanism is probably a good solution for you.

It does start processing before cluster is ready. It looks as soon as actor system is ready, you can send message to actors.

Thanks @TimMoore This looks like a good option. I will have a try.