Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running a Job only once Using Quartz

Is there a way I could run a job only once using Quartz in Java? I understand it does not make sense to use Quartz in this case. But, the thing is, I have multiple jobs and they are run multiple times. So, I am using Quartz.

Is this even possible?

like image 838
Kaddy Avatar asked Apr 26 '10 00:04

Kaddy


People also ask

How many jobs can quartz handle?

The actual number of jobs that can be running at any moment in time is limited by the size of the thread pool. If there are five threads in the pool, no more than five jobs can run at a time.

How does Quartz job work?

Quartz scheduler allows an enterprise to schedule a job at a specified date and time. It allows us to perform the operations to schedule or unschedule the jobs. It provides operations to start or stop or pause the scheduler. It also provides reminder services.

How do you schedule multiple jobs using quartz?

If you want to schedule multiple jobs in your console application you can simply call Scheduler. ScheduleJob (IScheduler) passing the job and the trigger you've previously created: IJobDetail firstJob = JobBuilder. Create<FirstJob>() .

How do I Unschedule a quartz job?

We can unschedule a Job by calling the unschedule() method of the Scheduler class and passing the TriggerKey . If the related job does not have any other triggers, and the job is not durable, then the job will also be deleted.


2 Answers

You should use SimpleTrigger that fires at specific time and without repeating. TriggerUtils has many handy methods for creating these kind of things.

like image 149
Marko Lahma Avatar answered Sep 28 '22 00:09

Marko Lahma


I'm not sure how much similar is Quartz in Mono and Java but this seems working in .Net

TriggerBuilder.Create ()
        .StartNow ()
        .Build (); 
like image 30
Puchacz Avatar answered Sep 28 '22 00:09

Puchacz