Akka石英调度程序不会触发作业

编程入门 行业动态 更新时间:2024-10-26 16:29:44
本文介绍了Akka石英调度程序不会触发作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我尝试在我的游戏项目中使用 akka-quartz-scheduler 。 我创建了两个akka演员,并为演员添加了配置:

I try to use this akka-quartz-scheduler in my play project. I created two akka actors, added configuration for actors:

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

我创建了模块,并在调度器和绑定调度器的地方添加了调度器:

I created module and add scheduler where i bind actors and scheduler:

protected void configure() { bindActor(HelloActor.class, HelloActor.NAME); bindActor(CleanupRunner.class, CleanupRunner.NAME); bind(QuartzSchedulerHelper.class).asEagerSingleton(); bind(QuartzSchedulerExtension.class).toProvider(SchedulerJobInitializer.class); } private static class SchedulerJobInitializer implements Provider<QuartzSchedulerExtension> { private final QuartzSchedulerExtension quartzSchedulerExtension; @Inject public SchedulerJobInitializer(ActorSystem actorSystem) { this.quartzSchedulerExtension = new QuartzSchedulerExtension((ExtendedActorSystem) actorSystem); } @Override public QuartzSchedulerExtension get() { return quartzSchedulerExtension; } }

应用程序启动时,我在日志中看到参与者已添加到调度程序中:

When application starts, I see in the log that actors were added to scheduler:

2018-07-06 11:51:44,947 [INFO] from org.quartz.impl.DirectSchedulerFactory in play-dev-mode-akka.actor.default-dispatcher-2 - Quartz scheduler 'QuartzScheduler~application 2018-07-06 11:51:44,947 [INFO] from org.quartz.impl.DirectSchedulerFactory in play-dev-mode-akka.actor.default-dispatcher-2 - Quartz scheduler version: 2.2.3 2018-07-06 11:51:44,950 [INFO] from org.quartz.core.QuartzScheduler in play-dev-mode-akka.actor.default-dispatcher-2 - Scheduler QuartzScheduler~application_$_application started. 2018-07-06 11:51:44,974 [INFO] from com.typesafe.akka.extension.quartz.QuartzSchedulerExtension in application-akka.actor.default-dispatcher-2 - Setting up scheduled job 'HELLO_ACTOR', with 'com.typesafe.akka.extension.quartz.QuartzCronSchedule@6a6c7b3b' 2018-07-06 11:51:45,005 [INFO] from com.typesafe.akka.extension.quartz.QuartzSchedulerExtension in application-akka.actor.default-dispatcher-2 - Setting up scheduled job 'CLEANUP_ACTOR', with 'com.typesafe.akka.extension.quartz.QuartzCronSchedule@2c32247d'

应该每10秒钟触发一次。任何不起作用的原因,或者我应该在什么地方添加?

Acotrs should be triggered every 10 seconds. Any reason why this do not work, or what should I add and where?

这里是 github上的代码。

推荐答案

您的日志摘要并不表示您的演员已在调度程序中注册。它显示的是Quartz作业已成功调度:在您的配置中, akka.quartz.schedules.HELLO_ACTOR 和 akka.quartz.schedules。 CLEANUP_ACTOR 是工作,而不是演员,尽管您已将其命名。 (我建议重命名这些作业以避免混淆。)

Your log snippet does not indicate that your actors are registered with the scheduler. What it does show is that the Quartz jobs are successfully scheduled: in your configuration, akka.quartz.schedules.HELLO_ACTOR and akka.quartz.schedules.CLEANUP_ACTOR are jobs, not actors, despite what you've named them. (I recommend renaming those jobs to avoid confusion.)

考虑您的 QuartzSchedulerHelper ,看来您的演员不是已向调度程序注册:

Considering your QuartzSchedulerHelper, it doesn't appear that your actors are registered with the scheduler:

List<String> actors = Arrays.asList(HelloActor.NAME, CleanupRunner.NAME); for (String name : actors) { ActorRef actor = registry.actorFor(name); schedule(quartzSchedulerExtension, actor, name, RandomStringUtils.randomAlphabetic(10)); }

actorFor 演员路径作为参数。您要传递给该方法的是演员的名字。使用actor路径:

actorFor takes an actor path as an argument. What you're passing to that method is the actor's name. Use the actor path:

String actorPath = "/user/" + name ActorRef actor = registry.actorFor(actorPath)

您可能还想尝试以下actor路径:

You might also want to try the following actor path:

String actorPath = "akka://application/user/" + name

更多推荐

Akka石英调度程序不会触发作业

本文发布于:2023-11-24 05:11:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624075.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   程序   Akka   石英

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!