3

With all due respect quartz is not very clear about repeatInterval in this question:

what happen if the method takes longer than the repeatInterval, is it going to fire the trigger even if the current method didn't finish? And is it going to cause connection pooling issue if the method create data source object?

say if the method normally takes 5 seconds to finish but may surge to 10 seconds, and repeatInterval is set to 8000 (8 seconds)

what will happen to the next occurrence of the trigger? I did some sample test and looks like it will occur in the 16th second because the first attempt at 8000 ms failed

is that the way it works? Is there any performance impact on the server?

Dreamer
  • 7,333
  • 24
  • 99
  • 179

1 Answers1

5

If the method execution takes longer than specified interval, the second instance of the job will be created and run concurrently.

You can annotate your Job instance with @DisallowConcurrentExecution annotation which prevents multiple instances of the job to run concurrently.

@DisallowConcurrentExecution
public class TestJob implements Job {}

Having this, the further attempted job instances will be queued up and you have to watch out, as without any control the infinite number of job instances may queue up which may lead to issues (such as performance, race-conditions, etc).

Is there any performance impact on the server?

As 2 jobs are performing the same operation this will have performance impact, depending on the operations you are trying to perform of course.

You can find alternatives of scheduling, also different approaches of preventing concurrent execution here.

Community
  • 1
  • 1
vtor
  • 8,989
  • 7
  • 51
  • 67
  • Thanks vtor. What is the answer if the `ConcurrentExecution` is already set to false, no current execution. if the method takes longer than the interval, when the next occurrence take place and any performance impact? – Dreamer Oct 07 '16 at 15:19
  • @Dreamer I've updated my answer, hope it helps >Having this, the further attempted job instances will be queued up and you have to watch out, as without any control the infinite number of job instances may queue up which may lead to issues (such as performance, race-conditions, etc). – vtor Oct 08 '16 at 10:13