Batch job is not executing - java

I am using Quartz & Spring Batch framework and scheduled almost 84 jobs. I have noticed recently that some of the jobs are not executing at all when above 80 jobs are scheduled to run.
If I schedule around 30 jobs then each jobs are executing on time and found no issue.
Not sure how to track down the root cause but i believe it could be the issue of unavailability of thread to each jobs. Any idea to sort out this issue ?

You can specify the number of threads:
org.quartz.threadPool.threadCount = 100
Look this post for default thread number: What is the quartz default thread count

Related

Hold the Scheduled Job Execution in SCDF until the previous job execution completes

I'm running SCDF in Openshift environment. I'm scheduling a Spring batch job to run once in every 5 minutes. Sometimes the job may run for more than 5 minutes. In that scenario, is it possible to hold the next scheduled job execution until the previous one completes its execution?
We don't want to change frequency of job execution also the interval.
Update 1:
Recently I found that with Kubernetes cronjob we can add concurrencyPolicy=forbid to stop the next job executions from happening if the previous one is still running.
I'm looking for equivalent configuration in SCDF.
Thanks.
Have a look at property spring.cloud.task.single-instance-enabled. Документация - Spring-cloud-task#features-single-instance-enabled
This prevents two tasks with the same name from running.
I checked on SCDF (2.6.1) and when running two identical tasks got the error:
Caused by: org.springframework.cloud.task.listener.TaskExecutionException: Task with name "timestamp-task" is already running.
at org.springframework.cloud.task.configuration.SingleInstanceTaskListener.lockTask(SingleInstanceTaskListener.java:121) ~[spring-cloud-task-core-2.2.3.RELEASE.jar!/:2.2.3.RELEASE]
... 31 common frames omitted

How to queue misfired jobs in Quartz?

Is there a way to queue thousands of misfired jobs in quartz scheduler?
I want to avoid having all misfired jobs to fire all at once.
We're using quartz 2.2.1.
Just limit the amount of concurrently executable jobs.
For example set the property org.quartz.threadPool.threadCount to 10 will cause that only 10 jobs could be executed in parallel. I.e. other jobs will be queued (depending on your MisfireInstructions).

Spring Scheduler Disallow Concurrent Alternative

When scheduling a task in Quartz, you have the ability to set misfires and rescheduling. This could be used in the example scenario whereby there is a job that runs every 30 mins, and potentially there could be a backlog and and the job would execute for longer than 30 mins. To prevent the same job running twice you could use the #DisallowConcurrentExecution. Once complete the job would then execute the second instance that is queued by using simpleSchedule().withMisfireHandlingInstructionNowWithExistingCount().
Now in Spring Scheduler there doesn't appear to be this fine grained ability, with just the fixed-rate and fixed-delay options to schedule it every 30 mins or wait 30 mins after the previous job completed. Without using the hammer route of restricting to a single thread, as I want to increase the thread count for other batch jobs to run concurrently, what would be the best method of recreating the Quartz behaviour?
So it looks like with the basic Spring Scheduler there isn't such a mechanism. To do this either use the Spring Quartz Scheduler, or Quartz directly.

Spring SchedukedTask strat only once

I am using spring3.2 for taskscheduling. I am currently run the job for every 3 hours
what i am looking is start the cron job initally when application starts but never again.
and how would i stop the scheduled task if i don't need means?
I am new to the Spring task scheduling. Please help me?

How to schedule multiple jobs in quartz scheduler using same trigger?

I am using quartz scheduler in my spring project. I have to run a job after another job which is scheduled to run in every 15 mins? I cant run this job concurrently as both of this jobs have to access same mail account using different protocols(one to send:smtp and other to receive: imap) and it may cause problems. Please reply quickly, as its an urgent requirement.
Just write a wrapper job class that launches second job after the first. You could then reuse separate jobs in the future if there will be any necessity.
You could do something with writing a job listener to recognize when the first job ends, and have it start the second. But the solution first suggested by mindas is easier - wrap both your jobs in another Job implementation, which is the one you actually schedule.

Categories

Resources