enragedginger/akka-quartz-scheduler

Date doesn't change after Friday.

Closed this issue · 1 comments

So we are using akka-quartz-scheduler for creating csv as part of a scheduled job which kicks off very 10 minutes (timing will change once application goes to prod).

My akka config looks like following :

akka {
	quartz {
  	  schedules {
  	    Every10Minutes {
  	      description = "A cron job that fires off every 10 minutes"
  	      expression = "0 0/10 * * * ?"
  	    }
  	  }
  	}
}

My scala code looks like following :

@PostConstruct
  def initMessageListener(): Unit = {
    val system = actorSystem
    //noinspection ScalaStyle
    val myManagerActor = system.actorOf(SpringExtension(system, ctx).props(senderManager), sender

Manager)
     QuartzSchedulerExtension(system).schedule("Every10Minutes", myManagerActor, getCurrentDate)  
  }

def getCurrentDate() : String = {
    val sdf = new SimpleDateFormat( "yyyy-MM-dd" );
    sdf.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
    sdf.format(new Date())    
  }

When my csv job is kicked off every 10 minutes, I am logging the message as following :
Received request to load json documents with date 2017-02-01 ",

QUERY

Assume that I started my application on Monday morning. The problem is that everything works fine till friday 11:59:59 PM. However the moment the day changes after Friday, the date parameter passed to scheduler expression never changes to Saturday's date and application continues invoke job with Friday's date.

We've observed this on two consecutive weeks and everything works fine on weekday but issue only comes after Fridays. Initially we thought it must be some random issue, however second time we realized that something is definitely not right and we have no idea why this is happening.

Need help on this and quick response is really appreciated.

Hi @smartmanav,

I think you're seeing the same issue from #50. Basically, when you call schedule, getCurrentDate is invoked and its result is returned. This is why everything works fine for the first day. I'm guessing there are redeploys and restarts of your app on weekdays which is why you're only seeing this issue on weekends. To get around this, just generate the date inside of the actor which receives the message from the tick per my comment in #50.

Does that help?