dropwizard-quartz icon indicating copy to clipboard operation
dropwizard-quartz copied to clipboard

integration issues with scheduler

Open vikeshpandey opened this issue 9 years ago • 1 comments

The readme.md has few improvement areas which i want to highlight. I am trying to integrate it with our project but scheduler looks angry and doesnt execute. Here are the points:

  • The interval example is incorrect. It has an incorrect constructor.
  • There is no explanation of what and why Mydep would be used.
  • There is no way shown to add it as a bundle to the bootstrap of dropwizard. Like we generally do in the initialize method.
  • what does the the "sandbox" param supposed to do? Please explain
  • I have done all it requires, writing the service and configuration class, writing the module class as it says and writing the job class as shown. But my "hello world" doesnt work. May be, i am doing something wrong here. The documentation can be improved to make it more explicit so that it is easy for first timers to integrate and run.

Apologies for pasting some code here itself, but i desperately need to get it up and running:

public class Test extends AutoConfigApplication<TestServiceConfiguration> {
    public Test () {
        super("revaliadation-scheduler", Test.class.getPackage().getName(), ManagedScheduler.class.getPackage().getName());
    }

    @Override
    protected Injector createInjector(TestServiceConfiguration configuration) {
        return super.createInjector(configuration).createChildInjector(new TestModule());
    }
}
=====================================================================
public class TestModule extends AbstractModule {
    @Override
    protected void configure() {
        bind(SchedulerConfiguration.class).toInstance(new SchedulerConfiguration("revalidation-scheduler"));
    }

    @Provides
    @Singleton
    Scheduler provideScheduler() throws SchedulerException {
        return StdSchedulerFactory.getDefaultScheduler();
    }
}
==========================================================================
@Scheduled(interval=2, unit= TimeUnit.SECONDS)
public class TokenGenerationJob implements Job {
    @Inject
    public TokenGenerationJob(){
    }
    public void execute(JobExecutionContext context) throws JobExecutionException {
     System.out.println("i m the job :-)") ;
    }
}
==========================================================================

the execute method never fires. I couldn't find any other place to post my query. Apologies again. Any quick pointers would really help here. TIA

vikeshpandey avatar Aug 28 '15 04:08 vikeshpandey

Could you push this code to a public repo / branch so I could take a closer look? At first glance there doesn't appear to be anything wrong with what you've pasted here. I'm curious as to the defined packages of each of the classes, and if you see anything in the logs on startup (as we log at INFO when we add scheduled jobs).

jaredstehler avatar Sep 08 '15 02:09 jaredstehler