Quartz scheduler - allow parallel job execution - quartz-scheduler

I am working on Quartz Scheduler and I don't know how to run jobs in parallel.
Is there something from config file that can allow me to do that ?

More details will help answer your question. But in general, a job can be executed in parallel if there are multiple triggers that are getting fired at the same time that reference this job. This is a feature that is provided by quartz.

Related

ScheduledExecutorService.scheduleWithFixedDelay usage in vertx

I would like schedule a task that gets executed periodically after the completion of task. Previously I used ScheduledExecutorService.scheduleWithFixedDelay but now in vertx I am thinking whether it may cause any issue since vertx already uses thread for event loop and worker verticles.
I checked Vertx.setPeriodic, but that just executes periodically without checking or waiting for the task to complete before scheduling other.
With all options explored currently I have a workaround where I use Vertx.setTimer to schedule the task and on completion I am calling Vertx.setTimer again inside the handler.
On high level the schedule task will query records from one table and update other table.
Anyone has any other better solution, please guide me.
Vertx version - 3.9.4
To my best knowledge ScheduledExecutorService.scheduleWithFixedDelay shouldn't cause any problems with Vert.x, and you can continue using it.
Your suggestion of setting timer in a callback is the better way of solving that, though.

Quartz: Undesired multiple job run in same time

I have some jobs that run with their schedule, but when I have for example two jobs that run in same time Quartz start one of this jobs two or three times. Did someone have the same problem? And how can I resolve this?
I am not entirely sure, but there could be copule reasons,
1). you are creating a new scheduler instance everytime you trigger/schedule job
2). or you are running the same exact Execute method of a class or have same job running eveytime.
So, when you declare your scheduler, instead of working on some other instance of scheduler, use default scheduler all time, for e.g.,
private IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
that is what I have done and I have a lot notifications/jobs triggering using Quartz.Net and haven't faced any issue yet.
Let me know if any of this helps. Cheers!

Setting up a Job Schedule

I currently have a setup that creates a job and then collect some metrics about the tasks in the job. I want to do something similar, but by setting a job schedule instead. In particular, I want to set a job schedule that wakes up at a recurrence interval that I specify, and run the same code that I was running when creating a job. What's the best way to go about doing that?
It seems that there is a CloudJobSchedule that I could use to set up my job schedule, but this only lets me create say a job manager task, and specify few properties. How can I run external code on the jobs created by the Job schedule?
It could also help to clarify how the CloudJobSchedule works. Specifically, after I commit my job schedule, what would happen programmatically. Does the code just move sequentially and run the rest of the code. In this case, does it make sense to get a reference to the last job created by the job schedule and run code on the job returned?
You'll want to create a CloudJobSchedule. You can specify the recurrence in the Schedule.
If you only need to run a single task per recurrence, your job manager task can simply be the task you need to run. If you need to run multiple tasks per job recurrence, your job manager needs to have logic to submit tasks to Batch and monitor for completion (if necessary).
When you submit a job schedule to Batch, your client side code will continue running. The behavior is no different than if you were submitting a regular job. You can retrieve the last job run via JobScheduleExecutionInformation and the RecentJob property.

Run scheduler to execute jobs at an interval from the completion of the previous job

I need to create schedulers to execute jobs(class files) at specified intervals..For Now, I'm using Quartz Scheduler which triggers the jobs at defined intervals from the time of triggering of it.
For Eg: Consider I'm giving a cron expression to run for every one hour starting at morning 9.My first run will be at 9 and my second run will be at 10 and so on.
If my job is taking 20 minutes to execute then in that case this method is not that much efficient.
What I need to do is to schedule a job for every one hour from the completion time of the previously ran job
For Eg: Consider my job to run every one hour is triggered at 9 and for the first run it took 20 minutes to run, so for the next time the job should trigger only at 10:20 instead of 10 (ie., one hour from the completion of previous ran job)
I need to know whether there are any methods in Quartz Scheduling to achieve this or any other logic I need to do.
If anyone could help me out on this,it would be very helpful for me.
You can easily achieve this by job-chaining your job executions. There are various approaches you can choose from:
(1) Implement a Quartz JobListener and in its jobWasExecuted method, that is invoked by Quartz whenever a job finishes executing, re-fire your job.
(2) Look at the Quartz JobChainingJobListener that you can use to implement simple job chaining scenarios. Please note that the functionality of this listener is very limited as it does not allow you to insert delays between job executions, there is no support for conditions that must be met before target jobs are executed etc. But you can use it as a good starting point to implement (1).
(3) Use QuartzDesk (our commercial product) or any other product that allows you to create job chains while externalizing and managing all job dependencies outside of your application. A job chain can have multiple target jobs that can be executed immediately, with a fixed delay or at arbitrary time in the future produced by a JavaScript expression. It also allows you to implement somewhat more sophisticated works flows, such as firing a target job when multiple source jobs complete their execution etc. I am attaching screenshots showing you what a simple job chain that re-executes Job1 with a 1 minute delay upon Job1's completion (with any job execution status) looks like:

How to trigger a method call every x minutes in Scala?

I'm planning a mechanism whose usage scenarios would be like cron's. It's a clock-ish mechanism that attempts task execution at prespecified times. Cron doesn't seem suitable, because these tasks trigger Scala method calls and the queue stored on a cloud database.
I imagine it like this: every x minutes, tasks' execution dates are retrieved from the database, and compared against current time, if the task is over-due it is executed and removed from queue.
My question is: how do I run the aforementioned check every x minutes on a distributed environment?
All advice encouraged.
I think the Akka scheduler might be what you are looking for. Here's a link to the Akka documentation and here's another link describing how to use Akka in Play.
Update: as Viktor Klang points out Akka is not a scheduler, however it does allow you to run a task periodically. I've used it in this mode quite successfully.
The best known library for this is Quartz Scheduler.