Spring Boot using Quartz in mode Cluster

Rafael Faita
Javarevisited
Published in
5 min readSep 23, 2020

--

TL;DR

By default, the Spring Boot library for Quartz doesn’t work correctly if you start up two instances of service in parallel. In this case, each one of the services starts the execution of the same jobs. The expected behavior is one of the instances is elected to execute the jobs, while the other ones waiting in the background, and in the case of failure in the first service, another one is elected to assume the jobs.

In this article, I will show how to configure Spring Boot to use Quartz with service in parallel execution(cluster).

If you want to read about How to cluster effectively Quartz jobs, check this link.

About Quartz

From the official site:

Quartz is a richly featured, open source job scheduling library that can be integrated within virtually any Java application — from the smallest stand-alone application to the largest e-commerce system. Quartz can be used to create simple or complex schedules for executing tens, hundreds, or even tens-of-thousands of jobs; jobs whose tasks are defined as standard Java components that may execute virtually anything you may program them to do. The Quartz Scheduler includes many enterprise-class features, such as support for JTA transactions and clustering.

Photo by Jiyeon Park on Unsplash

--

--