enragedginger/akka-quartz-scheduler

How to put two actors on the same schedule?

efrister opened this issue · 2 comments

Hi,

I have a scheduleconfigured that's named "EveryMinuteDuringWeekdays". I want two distinct actors to receive a Tick-message on that named schedule. If I schedule the ticket message for only one actor, it works fine. If I want to schedule it for the other actor as well, I get an exception.

Exception:
org.quartz.ObjectAlreadyExistsException: Unable to store Job : 'DEFAULT.EveryMinuteDuringWeekdays_Job', because one already exists with this identification.

Code:
val scheduler = QuartzSchedulerExtension(system = context.system) scheduler.schedule("EveryMinuteDuringWeekdays", self, Tick) scheduler.schedule("EveryMinuteDuringWeekdays", receiver, Tick)

Looking at the source of akka-quartz-scheduler I cannot seem to find the correct way on how I'd make sure that more than one actor can be on a schedule. Could you point me to the right direction?

It looks like this exception is coming from Quartz itself because that job name is already registered. Here's two options:

  1. Register the same schedule twice under two different names.
  2. When scheduling the job, point to a broadcast actor / pool that simply broadcasts the message to any actors that should receive the message. You can find more on broadcasting here.

Does that help?

Marking this as closed. Please reopen if this is still an issue.