IsaacLevon
IsaacLevon

Reputation: 2570

Quartz: Multiple Jobs that share a resource

I have multiple jobs and they all share the same resource. This resource is some ad-hoc build script, and so it cannot be ran concurrently.

Is it possible to define in Quartz that some jobs cannot run concurrently?

So, if one of the jobs is already running, the spawned job is queued.

Upvotes: 0

Views: 1048

Answers (1)

crazy_code
crazy_code

Reputation: 364

I had encounter a similar scenario in my application, try out the below approach and see if it works for you.

Put the code that runs your ad-hoc build script in a synchronized block. With this only one thread will run your ad-hoc script at a time, even when multiple threads are trying to run the same resource.

With this, you can increase the thread count to a suitable value as well instead of setting it to 1, like below. spring.quartz.properties.org.quartz.threadPool.threadCount=5

If you want to run multiple quartz scheduler instances on different machines sharing a single database, then you should consider Configure Clustering with JDBC-JobStore. Please refer this link for more info http://www.quartz-scheduler.org/documentation/quartz-2.2.2/configuration/ConfigJDBCJobStoreClustering.html

Upvotes: 3

Related Questions