I set up a job and instance by a parameter, but I can only execute one time. How can i config a job to allow it being executed unlimited times but by given any time only one job is running no concurrency allowed.
1
you could use a single thread task executor for your lob launcher.
@Bean
public JobLauncher jobLauncher() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(1);
executor.setMaxPoolSize(1);
executor.setQueueCapacity(500);
executor.setThreadNamePrefix("SingleThread-");
executor.initialize();
TaskExecutorJobLauncher jobLauncher = new TaskExecutorJobLauncher();
jobLauncher.setTaskExecutor(executor);
return jobLauncher;
}