Can we turn off and on Schedule conditionally?

34 views
Skip to first unread message

burk...@gmail.com

unread,
Apr 27, 2016, 1:46:54 PM4/27/16
to play-framework
Our system gets data from Oracle Database and processes. Once data bucket becomes empty, system needs to get data from Database again. We'd like to schedule this data retrieval part. If Database table is empty, system keeps trying to retrieve in every X mins. Once data bucket is filled up, then, system wants to turn off the schedule. Can we implement like this?

Adam Trousdale

unread,
Apr 27, 2016, 6:42:09 PM4/27/16
to play-framework
Why don't you build a scheduler that runs every X minutes and checks whether the bucket is empty? If it is empty it can execute the code to retrieve the data, if it isn't then it can do whatever you need it to for that scenario

burk...@gmail.com

unread,
Apr 29, 2016, 9:38:19 AM4/29/16
to play-framework
But even after data is retrieved, Scheduler will continuously run every X mins, right?

Adam Trousdale

unread,
Apr 29, 2016, 9:57:27 AM4/29/16
to play-framework
Yes the scheduler will run but you'll have introduced a check to see if the database is full. If it is then the scheduler runs without executing the retrieval code, if its not then it executes the retrieval code.

A very trivial example:

val isDatabaseFull = dbConnector.isDbFull

if (isDatabaseFull) // do nothing
else // retrieve data



This code would then be ran by the scheduler every X minutes
Reply all
Reply to author
Forward
0 new messages