knowm / dropwizard-sundial Goto Github PK
View Code? Open in Web Editor NEWScheduled jobs in dropwizard
License: Apache License 2.0
Scheduled jobs in dropwizard
License: Apache License 2.0
Hey all
Just curious if there's a good example for accessing the database object Dropwizard uses for my web requests within jobs. Is it a matter of adding that object to the application context?
Thanks
So that the scheduler loads it on startup, but it's just a manually triggered job. Eliminates need for jobs.xml in some cases.
I'm getting the following and I really have no idea what I am doing wrong. Double-checked everything, made a very simple example based on your README.md - it's always the same problem! :-(
INFO [2017-11-15 16:20:59,562] org.eclipse.jetty.server.Server: jetty-9.4.7.v20170914
INFO [2017-11-15 16:20:59,574] org.knowm.sundial.ee.SundialInitializerListener: Sundial Initializer Servlet loaded, initializing Scheduler...
INFO [2017-11-15 16:20:59,587] org.quartz.core.SchedulerSignalerImpl: Initialized Scheduler Signaler of type: class org.quartz.core.SchedulerSignalerImpl
INFO [2017-11-15 16:20:59,590] org.quartz.core.RAMJobStore: RAMJobStore initialized.
INFO [2017-11-15 16:20:59,590] org.quartz.plugins.xml.XMLSchedulingDataProcessorPlugin: Initializing XMLSchedulingDataProcessorPlugin Plug-in.
INFO [2017-11-15 16:20:59,590] org.quartz.plugins.management.ShutdownHookPlugin: Registering Quartz shutdown hook.
INFO [2017-11-15 16:20:59,590] org.knowm.sundial.plugins.AnnotationJobTriggerPlugin: Initializing AnnotationJobTriggerPlugin Plug-in.
INFO [2017-11-15 16:20:59,612] org.quartz.plugins.xml.XMLSchedulingDataProcessor: Parsing XML file: jobs.xml
INFO [2017-11-15 16:20:59,694] org.quartz.plugins.xml.XMLSchedulingDataProcessor: Adding 1 jobs, 1 triggers.
INFO [2017-11-15 16:20:59,694] org.quartz.plugins.xml.XMLSchedulingDataProcessor: Scheduled job: name: 'MyJob', Job Class: de.ddb.jobs.MyJob, description: null isConcurrencyAllowed: false, jobDataMap: [MyParam=42]
INFO [2017-11-15 16:20:59,694] org.quartz.plugins.xml.XMLSchedulingDataProcessor: Scheduled trigger: Trigger 'MyJob-Trigger', triggerClass: CronTriggerImpl, jobName: MyJob, jobDataMap: empty, calendar: null, misfireInstruction: 0, priority: 5, nextFireTime: null, cronEx: 0/45 * * * * ?, timeZone: Europe/Berlin
INFO [2017-11-15 16:20:59,696] org.knowm.sundial.plugins.AnnotationJobTriggerPlugin: Loading annotated jobs from de.ddb.jobs.MyJob.
ERROR [2017-11-15 16:20:59,698] org.knowm.sundial.ee.SundialInitializerListener: Sundial Scheduler failed to initialize:
! java.lang.RuntimeException: Unexpected problem: No resource for de/ddb/jobs/MyJob
! at org.quartz.classloading.CascadingClassLoadHelper.getJobClasses(CascadingClassLoadHelper.java:227)
! at org.knowm.sundial.plugins.AnnotationJobTriggerPlugin.start(AnnotationJobTriggerPlugin.java:88)
! at org.quartz.QuartzScheduler.startPlugins(QuartzScheduler.java:1113)
! at org.quartz.QuartzScheduler.start(QuartzScheduler.java:211)
! at org.knowm.sundial.ee.SundialInitializerListener.contextInitialized(SundialInitializerListener.java:122)
! at org.eclipse.jetty.server.handler.ContextHandler.callContextInitialized(ContextHandler.java:890)
! at org.eclipse.jetty.servlet.ServletContextHandler.callContextInitialized(ServletContextHandler.java:532)
! at org.eclipse.jetty.server.handler.ContextHandler.startContext(ContextHandler.java:853)
! at org.eclipse.jetty.servlet.ServletContextHandler.startContext(ServletContextHandler.java:344)
! at org.eclipse.jetty.server.handler.ContextHandler.doStart(ContextHandler.java:785)
! at org.eclipse.jetty.servlet.ServletContextHandler.doStart(ServletContextHandler.java:261)
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
! at com.codahale.metrics.jetty9.InstrumentedHandler.doStart(InstrumentedHandler.java:103)
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:113)
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
! at org.eclipse.jetty.server.handler.gzip.GzipHandler.doStart(GzipHandler.java:273)
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
! at org.eclipse.jetty.server.handler.StatisticsHandler.doStart(StatisticsHandler.java:252)
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.start(ContainerLifeCycle.java:131)
! at org.eclipse.jetty.server.Server.start(Server.java:449)
! at org.eclipse.jetty.util.component.ContainerLifeCycle.doStart(ContainerLifeCycle.java:105)
! at org.eclipse.jetty.server.handler.AbstractHandler.doStart(AbstractHandler.java:113)
! at org.eclipse.jetty.server.Server.doStart(Server.java:416)
! at org.eclipse.jetty.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
! at io.dropwizard.cli.ServerCommand.run(ServerCommand.java:53)
! at io.dropwizard.cli.EnvironmentCommand.run(EnvironmentCommand.java:44)
! at io.dropwizard.cli.ConfiguredCommand.run(ConfiguredCommand.java:85)
! at io.dropwizard.cli.Cli.run(Cli.java:75)
! at io.dropwizard.Application.run(Application.java:93)
! at de.ddb.MyApplication.main(MyApplication.java:27)
I am using Version 1.2.0.
Hi there! How can we set underlying thread pool priority? Thanks.
So I constantly ran into this error:
INFO [2016-05-18 13:20:15,003] org.quartz.classloading.CascadingClassLoadHelper: Package: 'nl.glu.voteapp.jobs' becomes Resource: 'file:/E:/Development/Studenten%20App/glu-app-backend/target/classes/nl/glu/voteapp/jobs'
ERROR [2016-05-18 13:20:15,006] org.knowm.sundial.ee.SundialInitializerListener: Sundial Scheduler failed to initialize:
! java.lang.NullPointerException: null
Then I removed the space in the directory name and it worked. I guess the fix is to not encode the directory path so that it doesn't add the %20 but instead uses a normal space.
Whenever I do a POST to /tasks/startjob?JOB_NAME={JobClassName} I get the following error:
WARN [2020-10-21 10:14:19,988] org.eclipse.jetty.server.HttpChannel: /tasks/startjob
! java.lang.AbstractMethodError: Receiver class org.knowm.dropwizard.sundial.tasks.StartJobTask does not define or inherit an implementation of the resolved method 'abstract void execute(java.util.Map, java.io.PrintWriter)' of abstract class io.dropwizard.servlets.tasks.Task.
I'm using dropwizard-sundial version 1.3.1 and dropwizard 2.0.13
I've been trying to use guice injection in the sundial job, but unfortunately it doesn't work.
I am using the following guice plugin for dropwizard: https://github.com/xvik/dropwizard-guicey
Maybe you could take a look at this?
Sorry for reporting it as a bug - didn't find any contact mail.
Thank you very much in advance!
Will this work in a clustered environment with more than one node running job code ? That would need database persistence support. Does that work for this ?
I see that sundial creates a new instance of scheduled object on every run. Can we avoid it and use the java timer like design. You create the object once and invokes the doRun() method on every schedule.
Hi, In my set up of dropwizard 0.9.2, /admin/tasks/startjob or /tasks/startjob as well as the other calls do not exist. I receive 404.
I don't use jobs.xml but I don't think the issue is related to that.
In the startup dropwizard lists only two tasks /tasks/log-level and /tasks/gc. The Sundial jobs are not listed.
Hello Tim,
I used sundial in one of our applications successfully... however, I'm getting a 404 when I run the curl command to alter the config or to stop the scheduler. For example, I have the applications running on port 9006 and hence the command be -
curl -X POST "http://localhost:9006/admin/tasks/stopjob?JOB_NAME=OMIJob"
But I do not see that the job is stopped. Also, when executed, I received a 404 on my log as follows -
{"@timestamp":"2016-04-12T16:30:17.051-05:00","level":"ERROR","message":"Web Application Exception occurred","message_id":"71f3df1b-1fec-4a55-8512-f770d33f2e50","caller_class_name":"com.srini.soa.errors.mappers.WebAppExceptionMapper","caller_method_name":"toResponse","caller_file_name":"WebAppExceptionMapper.java","caller_line_number":26,"stack_trace":"j.w.r.NotFoundException: HTTP 404 Not Found\n\tat o.g.j.s.ServerRuntime$2.run(ServerRuntime.java:323) ~[jersey-server-2.22.1.jar:na]\n\tat o.g.j.i.Errors$1.call(Errors.java:271) [jersey-common-2.22.1.jar:na]\n\tat o.g.j.i.Errors$1.call(Errors.java:267)\n\tat o.g.j.i.Errors.process(Errors.java:315)\n\tat o.g.j.i.Errors.process(Errors.java:297)\n\tat o.g.j.i.Errors.process(Errors.java:267)\n\tat o.g.j.p.i.RequestScope.runInScope(RequestScope.java:317)\n\tat o.g.j.s.ServerRuntime.process(ServerRuntime.java:305) [jersey-server-2.22.1.jar:na]\n\tat o.g.j.s.ApplicationHandler.handle(ApplicationHandler.java:1154)\n\tat o.g.j.s.WebComponent.serviceImpl(WebComponent.java:471) [jersey-container-servlet-core-2.22.1.jar:na]\n\tat o.g.j.s.WebComponent.service(WebComponent.java:425)\n\tat o.g.j.s.ServletContainer.service(ServletContainer.java:383)\n\tat o.g.j.s.ServletContainer.service(ServletContainer.java:336)\n\tat o.g.j.s.ServletContainer.service(ServletContainer.java:223)\n\tat i.d.j.NonblockingServletHolder.handle(NonblockingServletHolder.java:49) [dropwizard-jetty-0.9.1.jar:0.9.1]\n\tat o.e.j.s.ServletHandler$CachedChain.doFilter(ServletHandler.java:1669) [jetty-servlet-9.2.13.v20150730.jar:9.2.13.v20150730]\n\tat o.e.j.s.UserAgentFilter.doFilter(UserAgentFilter.java:83) [jetty-servlets-9.2.13.v20150730.jar:9.2.13.v20150730]\n\tat o.e.j.s.GzipFilter.doFilter(GzipFilter.java:300)\n\tat i.d.j.BiDiGzipFilter.doFilter(BiDiGzipFilter.java:132) [dropwizard-jetty-0.9.1.jar:0.9.1]\n\tat o.e.j.s.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [jetty-servlet-9.2.13.v20150730.jar:9.2.13.v20150730]\n\tat i.d.s.ThreadNameFilter.doFilter(ThreadNameFilter.java:29) [dropwizard-servlets-0.9.1.jar:0.9.1]\n\tat o.e.j.s.ServletHandler$CachedChain.doFilter(ServletHandler.java:1652) [jetty-servlet-9.2.13.v20150730.jar:9.2.13.v20150730]\n\tat i.d.j.f.AllowedMethodsFilter.handle(AllowedMethodsFilter.java:43) [dropwizard-jersey-0.9.1.jar:0.9.1]\n\tat i.d.j.f.AllowedMethodsFilter.doFilter(AllowedMethodsFilter.java:38)\n\tat o.e.j.s.ServletHandler$CachedChain.doFilter(ServletHan..."}
{"@timestamp":"2016-04-12T16:30:17.052-05:00","thread_name":"dw-114","message":"HTTP Response Log Entry","message_id":"71f3df1b-1fec-4a55-8512-f770d33f2e50","http_headers":{"Content-Length":"0","Date":"Tue, 12 Apr 2016 21:30:17 GMT"},"http_status_code":404,"response_time":2}
0:0:0:0:0:0:0:1 - - [12/Apr/2016:21:30:17 +0000] "POST /admin/tasks/stopjob?JOB_NAME=OMIJob HTTP/1.1" 404 0 "-" "curl/7.43.0" 3
Do I have to explicitly implement /admin/tasks/stopjob resources?
What am I missing here? Would you know?
Thanks,
Sripos
Hi @timmolter
I tried to add a job manually but everytime sundial throws an exception
SundialJobScheduler.addJob("emailJob","EmailJob");
SundialJobScheduler.addCronTrigger("testJob", "emailJob", "23 58 12 6 4 ?");
com.xeiam.sundial.SundialJobScheduler: ERROR ADDING JOB!!!
! java.lang.ClassNotFoundException: EmailJob
If I have job with a @SimpleTrigger
it keeps firing even with isConcurrencyAllowed = false
before the threads of that job are complete.
How do I go about telling the job to wait until it's spawned threads are complete before attempting to start again?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.