无法使用akka quartz调度程序第二次调度作业

bbuxkriu  于 2022-11-06  发布在  其他
关注(0)|答案(1)|浏览(229)

我无法第二次启动Akka Quartz调度程序。
我收到一个错误消息,说:

“插入构造函数时出错,org.quartz。调度程序异常:名为“QuartzScheduler~-application”的计划程序已存在”

public class JobModule extends AbstractModule implements ServiceGuiceSupport {

            @Override
            protected void configure() {
                //Akka Quartz Scheduler
                bind(QuartzSchedulerExtension.class).toProvider(SchedulerJobInitializer.class);

            }

            private static class SchedulerJobInitializer implements Provider<QuartzSchedulerExtension> {
                private QuartzSchedulerExtension quartzSchedulerExtension;

                @Inject
                public SchedulerJobInitializer(ActorSystem actorSystem) {
                        this.quartzSchedulerExtension = new QuartzSchedulerExtension((ExtendedActorSystem) actorSystem);
                }
                @Override
                public QuartzSchedulerExtension get() {
                    return quartzSchedulerExtension;
                }
            }
        }

       //Injecting in below class and it is failing

        public class JobScheduler {
            private final ActorSystem system;
            private final QuartzSchedulerExtension quartzSchedulerExtension;

            @Inject
            public JobScheduler(QuartzSchedulerExtension quartzSchedulerExtension,
                                 ActorSystem system) {
                this.quartzSchedulerExtension = quartzSchedulerExtension;
                this.system=system;
            }
        }

堆栈追踪:

Error injecting constructor, org.quartz.SchedulerException: Scheduler with name 'QuartzScheduler~feed-integration-impl-application' already exists.
  at com.aie.arc.feed.impl.module.FeedIntegrationModule$SchedulerJobInitializer.<init>(FeedIntegrationModule.java:83)
  while locating com.aie.arc.feed.impl.module.FeedIntegrationModule$SchedulerJobInitializer
  while locating com.typesafe.akka.extension.quartz.QuartzSchedulerExtension
    for the 3rd parameter of com.aie.arc.feed.impl.scheduler.FeedScheduler.<init>(FeedScheduler.java:40)
  while locating com.aie.arc.feed.impl.scheduler.FeedScheduler
    for the 5th parameter of com.aie.arc.feed.impl.service.FeedIntegrationServiceImpl.<init>(FeedIntegrationServiceImpl.java:69)
  at com.lightbend.lagom.javadsl.server.ServiceGuiceSupport$LagomServiceBuilder.bind(ServiceGuiceSupport.java:135) (via modules: com.google.inject.util.Modules$OverrideModule -> com.aie.arc.feed.impl.module.FeedIntegrationModule)
  while locating com.aie.arc.feed.impl.service.FeedIntegrationServiceImpl
  at com.lightbend.lagom.javadsl.server.ServiceGuiceSupport$LagomServiceBuilder.bind(ServiceGuiceSupport.java:153) (via modules: com.google.inject.util.Modules$OverrideModule -> com.aie.arc.feed.impl.module.FeedIntegrationModule)
  while locating com.lightbend.lagom.internal.javadsl.server.ResolvedServices
    for the 2nd parameter of com.lightbend.lagom.internal.server.ServiceRegistrationModule$RegisterWithServiceRegistry.<init>(ServiceRegistrationModule.scala:47)
  at com.lightbend.lagom.internal.server.ServiceRegistrationModule.bindings(ServiceRegistrationModule.scala:27):
Binding(class com.lightbend.lagom.internal.server.ServiceRegistrationModule$RegisterWithServiceRegistry to self eagerly) (via modules: com.google.inject.util.Modules$OverrideModule -> play.api.inject.guice.GuiceableModuleConversions$$anon$4)
  while locating com.lightbend.lagom.internal.server.ServiceRegistrationModule$RegisterWithServiceRegistry
Caused by: org.quartz.SchedulerException: Scheduler with name 'QuartzScheduler~feed-integration-impl-application' already exists.
    at org.quartz.impl.SchedulerRepository.bind(SchedulerRepository.java:80)
    at org.quartz.impl.DirectSchedulerFactory.createScheduler(DirectSchedulerFactory.java:529)
    at org.quartz.impl.DirectSchedulerFactory.createScheduler(DirectSchedulerFactory.java:415)
    at org.quartz.impl.DirectSchedulerFactory.createScheduler(DirectSchedulerFactory.java:372)
    at org.quartz.impl.DirectSchedulerFactory.createScheduler(DirectSchedulerFactory.java:330)
    at org.quartz.impl.DirectSchedulerFactory.createScheduler(DirectSchedulerFactory.java:298)
    at com.typesafe.akka.extension.quartz.QuartzSchedulerExtension.scheduler$lzycompute(QuartzSchedulerExtension.scala:436)
    at com.typesafe.akka.extension.quartz.QuartzSchedulerExtension.scheduler(QuartzSchedulerExtension.scala:433)
    at com.typesafe.akka.extension.quartz.QuartzSchedulerExtension.<init>(QuartzSchedulerExtension.scala:60)
    at com.aie.arc.feed.impl.module.FeedIntegrationModule$SchedulerJobInitializer.<init>(FeedIntegrationModule.java:84)
    at com.aie.arc.feed.impl.module.FeedIntegrationModule$SchedulerJobInitializer$$FastClassByGuice$$c1b5d634.newInstance(<generated>)
    at com.google.inject.internal.DefaultConstructionProxyFactory$FastClassProxy.newInstance(DefaultConstructionProxyFactory.java:89)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:114)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
    at com.google.inject.internal.BoundProviderFactory.get(BoundProviderFactory.java:60)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
    at com.google.inject.internal.SingleParameterInjector.inject(SingleParameterInjector.java:42)
    at com.google.inject.internal.SingleParameterInjector.getAll(SingleParameterInjector.java:65)
    at com.google.inject.internal.ConstructorInjector.provision(ConstructorInjector.java:113)
    at com.google.inject.internal.ConstructorInjector.construct(ConstructorInjector.java:91)
    at com.google.inject.internal.ConstructorBindingImpl$Factory.get(ConstructorBindingImpl.java:306)
    at com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40)
    at com.google.inject.internal.SingletonScope$1.get(SingletonScope.java:168)
    at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:39)
    at com.google.inject.internal.InjectorImpl$1.get(InjectorImpl.java:1050)
    at com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1086)
    at play.api.inject.guice.GuiceInjector.instanceOf(GuiceInjectorBuilder.scala:443)
    at play.api.inject.ContextClassLoaderInjector.$anonfun$instanceOf$3(Injector.scala:120)
    at play.api.inject.ContextClassLoaderInjector.withContext(Injector.scala:128)
22:19:56.727 [  at play.api.inject.ContextClassLoaderInjector.instanceOf(Injector.scala:120)
info    at com.lightbend.lagom.internal.javadsl.server.ResolvedServicesProvider.$anonfun$get$1(JavadslServerBuilder.scala:120)
zf2sa74q

zf2sa74q1#

正如刚才有人问的,你可能已经解决了这个问题。这里有一个解决方案,供那些碰巧也在那里绊倒的人使用。
我遇到了同样的问题。在尝试跟踪异常后,我决定单独运行编译,这提供了更多的信息。似乎发生了什么事,akka-quartz-schedule和akka-actor的版本不兼容。它花了一些战斗,但在我修复了依赖关系后,调度程序就开始工作了。

相关问题