I’m just having an issue with running schedulers in deployed containers of services in the swarm that running play framework as backend, the problem is if I scale that swarm to many Replicas actor system run schedulers in each replica without talking to each other, so the idea is clear to use the cluster, isn’t?
The first problem: Scaling is dynamic, and I can’t really configure ports for each instance, also the IP is dynamic, but still, I can use the hostname instead of IPs, what left for me is the port.
The second problem, I’m not sure how to configure the default play actor system to use the cluster?
This is a sample of code that starting up the scheduler:
private Cancellable startAlertsMaintainer(ActorSystem system, Duration initialDelay, Duration interval) {
logger.info("Maintainer Scheduler starting, first iteration will start after {} minutes with intervals of {} minutes", initialDelay.toMinutes(), interval.toMinutes());
return system.scheduler().scheduleAtFixedRate(
initialDelay,
interval,
() -> {
userAlertsMaintenanceService.maintainUserPreferences()
.thenAcceptAsync(aVoid -> logger.info("Users checked and subscriptions maintained"), system.dispatcher());
},
system.dispatcher()
);
}