【问题标题】:Cannot schedule job with akka quartz scheduler for second time无法第二次使用 akka 石英调度程序安排作业
【发布时间】:2019-08-20 17:05:34
【问题描述】:

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

“注入构造函数时出错,org.quartz.SchedulerException:名称为'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)

【问题讨论】:

    标签: akka scheduler quartz


    【解决方案1】:

    正如前段时间所问的那样,您可能已经解决了。对于碰巧也遇到这种情况的人,这里有一个解决方案。

    我遇到了同样的问题。在尝试跟踪异常后,我决定单独运行编译并提供更多信息。似乎发生了 akka-quartz-schedule 和 akka-actor 的版本不兼容的情况。花了一些时间,但在我修复了依赖关系之后,调度程序才开始工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-21
      • 2017-03-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多