enragedginger/akka-quartz-scheduler

Copy of message is send while invoking schedule method

sarikbansal opened this issue · 1 comments

Hi All,

I am using this scheduler in my application and found that whenever the schedule method is invoked then the copy of the message is being send down to the the sender class. example :-

schedule("EveryDayAt6AM", , new Date)

In the above example, I am passing new Date as the message to the actor. whenever the scheduler is invoked again then I was expecting the new Date but instead I am always getting the copy of the date object that was first send to the sender when the schedule method was invoked.

Is there a way to always send the new Date object to the sender using the quartz scheduler??

Hi @sarikbansal

The object passed as the third parameter to the schedule message is passed by reference to the actor. To get the desired functionality that you're looking for, you'll have to generate a new Date instance inside of that actor and then use that within your system. For the initial message to that actor, something like case object DoTheJob should do the trick:
schedule("EveryDayAt6AM", actorRef, DoTheJob)

def receive = {
  case DoTheJob =>
    val date = new Date()
    //do everything else here.
}