how to get control on scheduler job programatically like start and stop - java

we have requirement like to start, stop and resume individual job and get the status for individual job to display on web page. Please help me on the same to implement this functionality in Quartz Scheduler.

You should obtain a reference to the quartz Scheduler object, and you can do all from there. In spring you can obtain it through org.springframework.scheduling.quartz.SchedulerFactoryBean
Check this question for a better spring-quartz support.

Related

How to make a node able only to schedule Quartz jobs instead of executing them?

I have two Java Spring-Boot services, A and B, for which I need A to create Quartz jobs so B can fire them. B can schedule jobs as well, as long as A doesn't fire any.
I checked Quartz's configuration guide (http://www.quartz-scheduler.org/documentation/quartz-2.1.7/configuration/ConfigMain.html), but didn't find something meaningful there. I tried setting org.quartz.scheduler .batchTriggerAcquisitionMaxCount=0, but A was still able to fire triggers. Is there some property or anything that can support this?

Create dynamic Spring Batch job with Quartz based on user iput

I have question about approach I should use for my case. I have to schedule a job which will use user input (start date/time and file - user can pick start date/time and file on frontend). Job will do the same thing everytime, but with different file, cron expression and schedule name. So no functional changes in job - only different parameters.
For now there are java config classes with beans to configure jobs and I'm now thinking if it is possible to create new configuration class and change somehow parameters which I'm interested in? Or I shouldn't use beans and create a service where I will build everytime Job, JobDetails, Trigger etc and just schedule it?
I'm completely new in Spring Batch and I had to takeover this part from guy who left the team.
You need to dynamically create the schedule according to user input. Quartz provides the Trigger interface which you can implement as needed.
A similar question here: Dynamic Job Scheduling with Quartz or any other java api
Hope this helps.

Triggering Quartz job from JSF (Any front end)- How to wait for the job execution to be over

I am developing a front end to trigger a quartz job on the fly.
I have a form in the JSF page whose click action will dynamically trigger a quartz job.
The job is invoked by the following statement, the job is triggered and everything works fine.
scheduler.triggerJob("Job1",Scheduler.DEFAULT_GROUP,jobDataMap);
From what I understand the job seems to run in a separate thread and the execution of the calling function does not wait for the job to be over.
Since I am invoking the job from front end, I would like to wait till the job is over before I navigate to a different JSF page. So I can display an error message if the job fails.
I would also like to display a message to the user, "Processing job, please wait.." until the job is actually over.
Any ideas on how to accomplish this will be appreciated.
Thanks !
You can register a Trigger/Job Listener to be notified when a Quartz job has completed.
How you would get that asynchronous update back to the user in JSF, I'm not so sure. I would expect a good solution to depend on your application architecture, the version of JSF, and maybe even the library support you have available. It does sound like the kind of thing you'd expose as a pollable service and use an AJAX-updated component to me, though.

Quartz how to schedule an online action as a scheduled job?

I developed a web application and one of the function is to send emails.
I like to have the behaviour whereby the actual sending of emails is done in a batch job. Meaning when user click on the trigger button in online screen. The job for sending emails will be scheduled to run instead of immediately run.
How to do that exaclty? Any sample code references etc?
I would recommend Quartz website where I learnt Quartz.
For Spring integration, follow http://static.springsource.org/spring/docs/1.2.9/reference/scheduling.html
This tutorial will give you better idea how to schedule a job in quartz.
In example DumbJob.class will implement Job interface from Quartz and in turn provide execute() method. This method will contain batch job code.
I think what you really want to do is implement a queue / worker model here. The job gets added to a queue and periodically, workers poll the queue to determine if anything needs to be done.

Java – Create a workflow in Quartz

I am considering using the Quartz framework to schedule the run of several hundred jobs.
According to their API, jobs can be scheduled to run at certain moments in time but not to run one after the other (and stop a chain of jobs if one fails).
The only recommended methods I was able to find are:
Using a listener which notices the completion of a job and schedule the next trigger to fire (how to coordinate this?)
Each job will receive a parameter containing the next job to run and, after completing the actual work, schedule its run. (Cooperative)
Do you know a better method to create a workflow of jobs in Quartz?
Can you recommend other methods/framework for implementing a workflow in Java ?
EDITED: In the meantime I found out about OSWorkflow which appears to be a good match for what I need. It appears that what I need to implement is a "Sequence Pattern".
When Quartz documentation talks about "Job", it is referring to a class implementing the "Job" Interface, which is really just any class with an "execute" method that takes in the Quartz Context object. When creating this implementation you can really do whatever you want.
You could create an implementation of the Quartz Job Interface which simply calls all the jobs in your workflow in series, and throws a JobExecutionException exception on failure.
It sounds to me like you want Quartz to schedule the first job, and chain everything off that.
Have you looked at encapsulating each task using the Command Pattern, and linking them together ?
I've worked on a project called Dynamic Task Scheduler that use Quartz to execute job chains implementing a simple workflow in a fault-tolerant way (definied in XML format).
Take a look at http://sourceforge.net/projects/dynatasksched/
The project is beta, but I think it can gives you some ideas to start..
Hope it's useful!
For job chaining support for Quartz, you may want to check the QuartzDesk project that I have been involved in. In version 2.0. we have added a powerful job chaining engine that enables you to orchestrate your Quartz jobs without the need to modify your application code.
The engine takes care of propagating the job execution result and other parameters from the source job to the chained target job.
QuartzDesk comes with a GUI that allows you to dynamically update your job chains without disrupting your application.

Categories

Resources