import akka.util.Duration;
import org.joda.time.DateTime;
import org.joda.time.DateTimeConstants;
import play.Application;
import play.GlobalSettings;
import play.Logger;
import play.libs.Akka;
import java.util.concurrent.TimeUnit;
import static org.joda.time.Seconds.secondsBetween;
public class Global extends GlobalSettings {
@Override
public void onStart(Application application) {
DateTime now = new DateTime();
DateTime plannedStart = new DateTime()
.withDayOfWeek(DateTimeConstants.THURSDAY)
.withHourOfDay(14)
.withMinuteOfHour(3)
.withSecondOfMinute(0)
.withMillisOfSecond(0);
DateTime nextRun = (now.isAfter(plannedStart))
? plannedStart.plusWeeks(1)
: plannedStart;
Long nextRunInSeconds = (long) secondsBetween(now, nextRun).getSeconds();
Akka.system().scheduler().schedule(
Duration.create(nextRunInSeconds, TimeUnit.SECONDS),
Duration.create(5, TimeUnit.SECONDS) ,
new Runnable() {
public void run() {
Logger.info("I started at thursday and will return here in next 5 seconds, now it's " + new DateTime());
}
}
);
}
}
BTW, you don't need to creaty many topics for the same problem.