0

I am using quartz library, mainly to schedule multiple tasks that will run forever at specific time. I have a customized executor (a retry executor that reschedule a task for a specified number of times in case of failure (retries are customizable). I want to know if there is a way to setup quartz to use this customized executor? Currently I am using the executor inside the Job i.e. call executor.execute() inside the Job's execute method.

ata
  • 8,853
  • 8
  • 42
  • 68

1 Answers1

1

From the Guide there is only explained how to configure your own ThreadPool.

Fine-tuning the Scheduler

You can also implement Quatz's interface ThreadExecutor or adjust your "RetryExecutor" implementation to do so.

Then it can be passed as component via setThreadExecutor to the QuartzSchedulerResources which in turn are used to configure QuartzScheduler - the heart of Quartz.

Keep the Job isolated

It's discouraged to modify scheduling or execute additional jobs from within a job's execute method. This control-flow is kept outside from the jobs by Quartz. It's part of the Scheduler's responsibilities. Thus your current solution:

  • using the executor inside the Job i.e. call executor.execute() inside the Job's execute method

can inflict the correct function of the Scheduler itself.

Retry controlled from within the job

There might be a couple of ways how to deal with retries in Quartz. Take a search here in Stackoverflow for [quartz-scheduler] retry:

  • Automatic retry of failed jobs
  • Count-based retries, increasing delays between retries, etc.

This question explains some: Quartz retry when failure

hc_dev
  • 8,389
  • 1
  • 26
  • 38