我正在尝试使用 akka-quartz-scheduler 定期触发清理事件。我让调度程序将消息发送给参与者,但前提是没有与调度关联的日历。每当我将日历附加到日程表时,演员都不会收到任何消息。
这是与 akka-quartz-scheduler 相关的 application.conf 部分。如果我删除线
日历 = ["最小"]"
从配置中,我的演员被触发。如果我把线路留在里面,没有演员会被叫到。
akka {
quartz {
defaultTimezone = "Europe/Oslo"
schedules {
NowAndThen {
description ="Delete temp files now and then, eg every hour"
expression = "*/10 * * * * ?"
calendars = ["Minimal"]
}
}
calendars {
Minimal {
type = Daily
exclude {
startTime = "15:00"
endTime = "15:01"
}
}
}
}
}
我正在 Global.java 中从 playframework 应用程序初始化扩展:
import akka.actor.ActorRef;
import akka.actor.ActorSystem;
import akka.actor.Extension;
import akka.actor.Props;
import com.typesafe.akka.extension.quartz.QuartzSchedulerExtension;
import play.Application;
import play.GlobalSettings;
import play.Logger;
import play.libs.Akka;
import uttrekk.CleanupRunner;
public class Global extends GlobalSettings {
public void onStart(Application app) {
AkkaStartUp.startup(app);
}
static class AkkaStartUp {
public static void startup(Application app) {
// Starter autoamtiske avelveringer norges eiendommer
ActorSystem system = Akka.system();
ActorRef cleanupRef =system.actorOf(new Props(CleanupRunner.class));
QuartzSchedulerExtension scheduler = (QuartzSchedulerExtension) QuartzSchedulerExtension.get(system);
scheduler.schedule("NowAndThen",cleanupRef,"Clean");
}
}
}
Actor 实现如下所示:
package uttrekk;
import akka.actor.UntypedActor;
import play.Logger;
import util.NewProperties;
import java.io.File;
import java.io.FilenameFilter;
public class CleanupRunner extends UntypedActor {
@Override
public void onReceive(Object message) throws Exception {
Logger.info("Running cleanup of temporary files");
}
}