Java Code Examples for org.springframework.batch.core.launch.support.SimpleJobLauncher#setTaskExecutor()

The following examples show how to use org.springframework.batch.core.launch.support.SimpleJobLauncher#setTaskExecutor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpringBatchConfiguration.java    From spring-cloud with Apache License 2.0 5 votes vote down vote up
private JobLauncher createJobLauncher() throws Exception {
    SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
    jobLauncher.setJobRepository(jobRepository);
    jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor());
    jobLauncher.afterPropertiesSet();
    return jobLauncher;
}
 
Example 2
Source File: JobTaskScheduled.java    From j360-dubbo-app-all with Apache License 2.0 5 votes vote down vote up
public void run() {
    long timeCount = count.incrementAndGet();
    log.info("任务执行开始 [count={}, date={}]",timeCount, DateFormatUtil.formatDate(DateFormatUtil.PATTERN_DEFAULT_ON_SECOND, new Date()));
    SimpleJobLauncher launcher = new SimpleJobLauncher();
    launcher.setJobRepository(jobRepository);
    launcher.setTaskExecutor(new SimpleAsyncTaskExecutor());
    try {
        launcher.run(batchJob, new JobParameters());
    } catch (Exception e) {
        log.error("任务执行失败 [count={}, date={}]", timeCount, DateFormatUtil.formatDate(DateFormatUtil.PATTERN_DEFAULT_ON_SECOND, new Date()),e);
    } finally {
        log.info("任务执行结束 [count={}, date={}]",timeCount, DateFormatUtil.formatDate(DateFormatUtil.PATTERN_DEFAULT_ON_SECOND, new Date()));
    }

}
 
Example 3
Source File: SpringBatchLightminBatchConfiguration.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
@Bean(name = "defaultAsyncJobLauncher")
public JobLauncher defaultAsyncJobLauncher(final JobRepository jobRepository) {
    final SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
    jobLauncher.setJobRepository(jobRepository);
    jobLauncher.setTaskExecutor(new SimpleAsyncTaskExecutor());
    return jobLauncher;
}
 
Example 4
Source File: TaskJobLauncherCommandLineRunnerCoreTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Override
public JobLauncher getJobLauncher() {
	SimpleJobLauncher launcher = new SimpleJobLauncher();
	launcher.setJobRepository(this.jobRepository);
	launcher.setTaskExecutor(new SyncTaskExecutor());
	return launcher;
}
 
Example 5
Source File: TaskJobLauncherCommandLineRunnerTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
protected JobLauncher createJobLauncher() throws Exception {
	SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
	jobLauncher.setJobRepository(getJobRepository());
	jobLauncher.setTaskExecutor(new ConcurrentTaskExecutor());
	jobLauncher.afterPropertiesSet();
	return jobLauncher;
}
 
Example 6
Source File: TaskExecutorBatchConfiguration.java    From spring-boot-starter-batch-web with Apache License 2.0 5 votes vote down vote up
private JobLauncher createJobLauncher() throws Exception {
	SimpleJobLauncher simpleJobLauncher = new SimpleJobLauncher();
	simpleJobLauncher.setJobRepository(jobRepository);
	simpleJobLauncher.setTaskExecutor(taskExecutor);
	simpleJobLauncher.afterPropertiesSet();
	return simpleJobLauncher;
}
 
Example 7
Source File: JpaBatchConfigurer.java    From spring4-sandbox with Apache License 2.0 5 votes vote down vote up
private JobLauncher createJobLauncher() throws Exception {
	SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
	jobLauncher.setJobRepository(jobRepository);
	jobLauncher.setTaskExecutor( new SimpleAsyncTaskExecutor());
	jobLauncher.afterPropertiesSet();
	return jobLauncher;
}
 
Example 8
Source File: AdHocBatchConfig.java    From spring-batch-rest with Apache License 2.0 4 votes vote down vote up
public JobLauncher getJobLauncher() {
    SimpleJobLauncher jobLauncher = new SimpleJobLauncher();
    jobLauncher.setJobRepository(jobRepository);
    jobLauncher.setTaskExecutor(new ConcurrentTaskExecutor(executorService));
    return jobLauncher;
}