org.springframework.batch.core.configuration.annotation.JobBuilderFactory Java Examples

The following examples show how to use org.springframework.batch.core.configuration.annotation.JobBuilderFactory. 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: BatchConfiguration.java    From building-microservices with Apache License 2.0 7 votes vote down vote up
@Bean
Job personEtl(JobBuilderFactory jobBuilderFactory,
        StepBuilderFactory stepBuilderFactory,
        FlatFileItemReader<Person> reader,
        JdbcBatchItemWriter<Person> writer
) {

    Step step = stepBuilderFactory.get("file-to-database")
            .<Person, Person>chunk(5)
            .reader(reader)
            .writer(writer)
            .build();

    return jobBuilderFactory.get("etl")
            .start(step)
            .build();
}
 
Example #2
Source File: RemoteConfiguration.java    From CogStack-Pipeline with Apache License 2.0 7 votes vote down vote up
@Bean
public Job job(JobBuilderFactory jobs,
               StepBuilderFactory steps,
               Partitioner partitioner,
               @Qualifier("partitionHandler") PartitionHandler partitionHandler,
               JobCompleteNotificationListener jobCompleteNotificationListener,
               @Qualifier("tLJobParametersIncrementer") TLJobParametersIncrementer runIdIncrementer

               ) {
    return jobs.get(jobName)
            .incrementer(runIdIncrementer)
            .listener(jobCompleteNotificationListener)
            .flow(
                    steps
                            .get(jobName + "MasterStep")
                            .partitioner((jobName+"SlaveStep"), partitioner)
                            .partitionHandler(partitionHandler)
                            .build()
            )
            .end()
            .build();

}
 
Example #3
Source File: LocalConfiguration.java    From CogStack-Pipeline with Apache License 2.0 6 votes vote down vote up
@Bean
public Job job(JobBuilderFactory jobs,
               StepBuilderFactory steps,
               Partitioner partitioner,
               JobCompleteNotificationListener jobCompleteNotificationListener,
               @Qualifier("partitionHandler") PartitionHandler partitionHandler,
               @Qualifier("tLJobParametersIncrementer") TLJobParametersIncrementer runIdIncrementer

) {
    return jobs.get(env.getProperty("job.jobName"))
            .incrementer(runIdIncrementer)
            .listener(jobCompleteNotificationListener)
            .flow(
                    steps
                            .get(jobName + "MasterStep")
                            .partitioner((jobName+"SlaveStep"), partitioner)
                            .partitionHandler(partitionHandler)
                            .build()
            )
            .end()
            .build();

}
 
Example #4
Source File: SpringBatchFlowRunner.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
SpringBatchFlowRunner(StepBuilderFactory stepBuilderFactory,
		JobBuilderFactory jobBuilderFactory,
		ProjectsToRunFactory projectsToRunFactory, JobLauncher jobLauncher,
		FlowRunnerTaskExecutorSupplier flowRunnerTaskExecutorSupplier,
		ConfigurableApplicationContext context, ReleaserProperties releaserProperties,
		BuildReportHandler reportHandler) {
	this.stepBuilderFactory = stepBuilderFactory;
	this.jobBuilderFactory = jobBuilderFactory;
	this.projectsToRunFactory = projectsToRunFactory;
	this.jobLauncher = jobLauncher;
	this.flowRunnerTaskExecutorSupplier = flowRunnerTaskExecutorSupplier;
	this.stepSkipper = new ConsoleInputStepSkipper(context, reportHandler);
	this.releaserProperties = releaserProperties;
	this.executorService = Executors.newFixedThreadPool(
			this.releaserProperties.getMetaRelease().getReleaseGroupThreadCount());
}
 
Example #5
Source File: AbstractSpringAcceptanceTests.java    From spring-cloud-release-tools with Apache License 2.0 6 votes vote down vote up
@Bean
SpringBatchFlowRunner mySpringBatchFlowRunner(
		StepBuilderFactory stepBuilderFactory,
		JobBuilderFactory jobBuilderFactory,
		ProjectsToRunFactory projectsToRunFactory, JobLauncher jobLauncher,
		FlowRunnerTaskExecutorSupplier flowRunnerTaskExecutorSupplier,
		ConfigurableApplicationContext context,
		ReleaserProperties releaserProperties, BuildReportHandler reportHandler) {
	return new SpringBatchFlowRunner(stepBuilderFactory, jobBuilderFactory,
			projectsToRunFactory, jobLauncher, flowRunnerTaskExecutorSupplier,
			context, releaserProperties, reportHandler) {
		@Override
		Decision decide(Options options, ReleaserTask task) {
			return Decision.CONTINUE;
		}
	};
}
 
Example #6
Source File: TaskJobLauncherCommandLineRunnerCoreTests.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
@Before
public void init() {
	this.jobs = new JobBuilderFactory(this.jobRepository);
	this.steps = new StepBuilderFactory(this.jobRepository, this.transactionManager);
	Tasklet tasklet = (contribution, chunkContext) -> RepeatStatus.FINISHED;
	this.step = this.steps.get("step").tasklet(tasklet).build();
	this.job = this.jobs.get("job").start(this.step).build();
	this.runner = new TaskJobLauncherCommandLineRunner(this.jobLauncher,
			this.jobExplorer, this.jobRepository, new TaskBatchProperties());

}
 
Example #7
Source File: AddressMigrationJobConfiguration.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
@Bean
public Job addressMigrationJob(final JobBuilderFactory jobBuilderFactory,
                               final Step addressMigrationStep) throws Exception {
    return jobBuilderFactory.get("addressMigrationJob")
            .start(addressMigrationStep)
            .build();
}
 
Example #8
Source File: AddressImportJobConfiguration.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
@Bean
public Job addressImportJob(final Step addressImportStep,
                            final Step deleteFileStep,
                            final JobBuilderFactory jobBuilderFactory) {
    return jobBuilderFactory
            .get("addressImportJob")
            .start(addressImportStep)
            .next(deleteFileStep)
            .build();
}
 
Example #9
Source File: BatchConfiguration.java    From messaging with Apache License 2.0 5 votes vote down vote up
@Bean
Job job(JobBuilderFactory jobBuilderFactory,
 StepBuilderFactory stepBuilderFactory, JdbcTemplate template,
 ItemReader<Contact> fileReader,
 ItemProcessor<Contact, Contact> emailProcessor,
 ItemWriter<Contact> jdbcWriter) {

 Step setup = stepBuilderFactory.get("clean-contact-table")
  .tasklet((contribution, chunkContext) -> {
   template.update("delete from CONTACT");
   return RepeatStatus.FINISHED;
  }).build();

 Step fileToJdbc = stepBuilderFactory.get("file-to-jdbc-fileToJdbc")
  .<Contact, Contact>chunk(5)
  // <1>
  .reader(fileReader).processor(emailProcessor).writer(jdbcWriter)
  .faultTolerant().skip(InvalidEmailException.class)
  // <2>
  .skipPolicy((Throwable t, int skipCount) -> {
   LogFactory.getLog(getClass()).info("skipping ");
   return t.getClass().isAssignableFrom(InvalidEmailException.class);
  }).retry(HttpStatusCodeException.class) // <3>
  .retryLimit(2).build();

 return jobBuilderFactory.get("etl") // <4>
  .start(setup).next(fileToJdbc).build();
}
 
Example #10
Source File: BatchConfiguration.java    From spring-cloud-release-tools with Apache License 2.0 5 votes vote down vote up
@Bean
@ConditionalOnMissingBean
FlowRunner flowRunner(StepBuilderFactory stepBuilderFactory,
		JobBuilderFactory jobBuilderFactory,
		ProjectsToRunFactory projectsToRunFactory, JobLauncher jobLauncher,
		FlowRunnerTaskExecutorSupplier flowRunnerTaskExecutorSupplier,
		ConfigurableApplicationContext context, ReleaserProperties releaserProperties,
		BuildReportHandler reportHandler) {
	return new SpringBatchFlowRunner(stepBuilderFactory, jobBuilderFactory,
			projectsToRunFactory, jobLauncher, flowRunnerTaskExecutorSupplier,
			context, releaserProperties, reportHandler);
}
 
Example #11
Source File: BatchConfig.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
public Job importUserJob(JobBuilderFactory jobs, Step step1, Step step2, JobExecutionListener listener) {
       return jobs.get("importUserJob")
               .incrementer(new RunIdIncrementer())
               .listener(listener)
               .flow(step1)
               .next(step2)
               .end()
               .build();
 }
 
Example #12
Source File: AddressPrinterJobConfiguration.java    From spring-batch-lightmin with Apache License 2.0 5 votes vote down vote up
@Bean
public Job addressPrinterJob(final JobBuilderFactory jobBuilderFactory,
                             final Step addressPrinterStep,
                             final Step addressBatchTaskDeletionStep) throws Exception {
    return jobBuilderFactory
            .get("addressPrinterJob")
            .incrementer(new RunIdIncrementer())
            .start(addressPrinterStep)
            .next(addressBatchTaskDeletionStep)
            .build();
}
 
Example #13
Source File: SingleStepJobAutoConfiguration.java    From spring-cloud-task with Apache License 2.0 5 votes vote down vote up
public SingleStepJobAutoConfiguration(JobBuilderFactory jobBuilderFactory,
		StepBuilderFactory stepBuilderFactory, SingleStepJobProperties properties,
		ApplicationContext context) {

	validateProperties(properties);

	this.jobBuilderFactory = jobBuilderFactory;
	this.stepBuilderFactory = stepBuilderFactory;
	this.properties = properties;
}
 
Example #14
Source File: NumberInfoConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
@Qualifier("first_job")
public Job numberGeneratorNonNotifierJob(JobBuilderFactory jobBuilderFactory, StepBuilderFactory stepBuilderFactory, @Qualifier("NotificationStep") Step notificationStep) {
    int[] nonNotifierData = { -1, -2, -3 };
    Step step = numberGeneratorStep(stepBuilderFactory, nonNotifierData, "First Dataset Processor");
    return jobBuilderFactory.get("Number generator - first dataset")
        .start(step)
        .on(NOTIFY)
        .to(notificationStep)
        .from(step)
        .on("*")
        .stop()
        .end()
        .build();
}
 
Example #15
Source File: NumberInfoConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
@Qualifier("second_job")
public Job numberGeneratorNotifierJob(JobBuilderFactory jobBuilderFactory, StepBuilderFactory stepBuilderFactory, @Qualifier("NotificationStep") Step notificationStep) {
    int[] billableData = { 11, -2, -3 };
    Step dataProviderStep = numberGeneratorStep(stepBuilderFactory, billableData, "Second Dataset Processor");
    return jobBuilderFactory.get("Number generator - second dataset")
        .start(dataProviderStep)
        .on(NOTIFY)
        .to(notificationStep)
        .end()
        .build();
}
 
Example #16
Source File: CapitalizeNamesJobConfig.java    From spring-batch with MIT License 5 votes vote down vote up
@Bean
public Job capitalizeNamesJob(JobBuilderFactory jobBuilders,
    StepBuilderFactory stepBuilders) {
  return jobBuilders.get("capitalizeNamesJob")
      .start(capitalizeNamesStep(stepBuilders))
      .next(deleteFilesStep(stepBuilders)).build();
}
 
Example #17
Source File: NumberInfoConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
@Qualifier("third_job")
@Primary
public Job numberGeneratorNotifierJobWithDecider(JobBuilderFactory jobBuilderFactory, StepBuilderFactory stepBuilderFactory, @Qualifier("NotificationStep") Step notificationStep) {
    int[] billableData = { 11, -2, -3 };
    Step dataProviderStep = numberGeneratorStepDecider(stepBuilderFactory, billableData, "Third Dataset Processor");
    return jobBuilderFactory.get("Number generator - third dataset")
        .start(dataProviderStep)
        .next(new NumberInfoDecider())
        .on(NOTIFY)
        .to(notificationStep)
        .end()
        .build();
}
 
Example #18
Source File: AdHocScheduler.java    From spring-batch-rest with Apache License 2.0 5 votes vote down vote up
@Autowired
public AdHocScheduler(JobBuilder jobBuilder, Scheduler scheduler, JobBuilderFactory jobBuilderFactory,
		StepBuilderFactory stepBuilderFactory) {
	this.jobBuilder = jobBuilder;
	this.scheduler = scheduler;
	this.jobBuilderFactory = jobBuilderFactory;
	this.stepBuilderFactory = stepBuilderFactory;
}
 
Example #19
Source File: AppConfig.java    From SpringBootBucket with MIT License 5 votes vote down vote up
/**
 * Job定义,我们要实际执行的任务,包含一个或多个Step
 *
 * @param jobBuilderFactory
 * @param s1
 * @return
 */
@Bean(name = "zappJob")
public Job zappJob(JobBuilderFactory jobBuilderFactory, @Qualifier("zappStep1") Step s1) {
    return jobBuilderFactory.get("zappJob")
            .incrementer(new RunIdIncrementer())
            .flow(s1)//为Job指定Step
            .end()
            .listener(new MyJobListener())//绑定监听器csvJobListener
            .build();
}
 
Example #20
Source File: LogConfig.java    From SpringBootBucket with MIT License 5 votes vote down vote up
/**
 * Job定义,我们要实际执行的任务,包含一个或多个Step
 *
 * @param jobBuilderFactory
 * @param s1
 * @return
 */
@Bean(name = "zlogJob")
public Job zlogJob(JobBuilderFactory jobBuilderFactory, @Qualifier("logStep1") Step s1) {
    return jobBuilderFactory.get("zlogJob")
            .incrementer(new RunIdIncrementer())
            .flow(s1)//为Job指定Step
            .end()
            .listener(new MyJobListener())//绑定监听器csvJobListener
            .build();
}
 
Example #21
Source File: CantonConfig.java    From SpringBootBucket with MIT License 5 votes vote down vote up
/**
 * Job定义,我们要实际执行的任务,包含一个或多个Step
 *
 * @param jobBuilderFactory
 * @param s1
 * @return
 */
@Bean(name = "cantonJob")
public Job cantonJob(JobBuilderFactory jobBuilderFactory, @Qualifier("cantonStep1") Step s1) {
    return jobBuilderFactory.get("cantonJob")
            .incrementer(new RunIdIncrementer())
            .flow(s1)//为Job指定Step
            .end()
            .listener(new MyJobListener())//绑定监听器csvJobListener
            .build();
}
 
Example #22
Source File: BudgetVtollConfig.java    From SpringBootBucket with MIT License 5 votes vote down vote up
/**
 * Job定义,我们要实际执行的任务,包含一个或多个Step
 *
 * @param jobBuilderFactory
 * @param s1
 * @return
 */
@Bean(name = "vtollJob")
public Job vtollJob(JobBuilderFactory jobBuilderFactory, @Qualifier("vtollStep1") Step s1) {
    return jobBuilderFactory.get("vtollJob")
            .incrementer(new RunIdIncrementer())
            .flow(s1)//为Job指定Step
            .end()
            .listener(new MyJobListener())//绑定监听器csvJobListener
            .build();
}
 
Example #23
Source File: BatchConfiguration.java    From Software-Architecture-with-Spring-5.0 with MIT License 5 votes vote down vote up
@Bean
public Job javaChampionsLoader(JobBuilderFactory jobs, @Qualifier(STEP_PROCESS_CSV_FILE) Step step) {
    return jobs.get(JAVA_CHAMPIONS_LOADER_JOB)
            .flow(step)
            .end()
            .build();
}
 
Example #24
Source File: CsvBatchConfig.java    From Demo with Apache License 2.0 5 votes vote down vote up
@Bean
public Job importJob(JobBuilderFactory jobs, Step s1) {
    return jobs.get("importJob")
            .incrementer(new RunIdIncrementer())
            .flow(s1) //为 job 指定 step
            .end()
            .listener(csvJobListener()) //绑定监听器 csvJobListener
            .build();
}
 
Example #25
Source File: JpaBatchConfigurer.java    From spring4-sandbox with Apache License 2.0 4 votes vote down vote up
@Bean
public JobBuilderFactory jobBuilderFactory(JobRepository jobRepository){
	return new JobBuilderFactory(jobRepository);
}
 
Example #26
Source File: EmbeddedTestApplication.java    From spring-batch-lightmin with Apache License 2.0 4 votes vote down vote up
@Autowired
JobConfiguration(final JobBuilderFactory jobBuilderFactory, final StepBuilderFactory stepBuilderFactory) {
    this.jobBuilderFactory = jobBuilderFactory;
    this.stepBuilderFactory = stepBuilderFactory;
}
 
Example #27
Source File: SpringBatchLightminBatchConfiguration.java    From spring-batch-lightmin with Apache License 2.0 4 votes vote down vote up
@Bean
@ConditionalOnMissingBean(value = {JobBuilderFactory.class})
public JobBuilderFactory jobBuilderFactory(final JobRepository jobRepository) {
    return new JobBuilderFactory(jobRepository);
}
 
Example #28
Source File: ContactBatchJobConfiguration.java    From building-microservices with Apache License 2.0 4 votes vote down vote up
@Bean
public Job importUserJob(JobBuilderFactory jobs, Step s1) {
	return jobs.get("importUserJob").incrementer(new RunIdIncrementer()).flow(s1)
			.end().build();
}
 
Example #29
Source File: HelloWorldJobConfig.java    From spring-batch with MIT License 4 votes vote down vote up
@Bean
public Job helloWorlJob(JobBuilderFactory jobBuilders,
    StepBuilderFactory stepBuilders) {
  return jobBuilders.get("helloWorldJob")
      .start(helloWorldStep(stepBuilders)).build();
}
 
Example #30
Source File: CapitalizeNamesJobConfig.java    From spring-batch with MIT License 4 votes vote down vote up
@Bean
public Job convertNamesJob(JobBuilderFactory jobBuilders,
    StepBuilderFactory stepBuilders) {
  return jobBuilders.get("capitalizeNamesJob")
      .start(convertNamesStep(stepBuilders)).build();
}