org.springframework.batch.core.Step Java Examples

The following examples show how to use org.springframework.batch.core.Step. 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: BudgetVtollConfig.java    From SpringBootBucket with MIT License 6 votes vote down vote up
/**
     * step步骤,包含ItemReader,ItemProcessor和ItemWriter
     *
     * @param stepBuilderFactory
     * @param reader
     * @param writer
     * @param processor
     * @return
     */
    @Bean(name = "vtollStep1")
    public Step vtollStep1(StepBuilderFactory stepBuilderFactory,
                           @Qualifier("vtollReader") ItemReader<BudgetVtoll> reader,
                           @Qualifier("vtollWriter") ItemWriter<BudgetVtoll> writer,
                           @Qualifier("vtollProcessor") ItemProcessor<BudgetVtoll, BudgetVtoll> processor) {
        return stepBuilderFactory
                .get("vtollStep1")
                .<BudgetVtoll, BudgetVtoll>chunk(5000)//批处理每次提交5000条数据
                .reader(reader)//给step绑定reader
                .processor(processor)//给step绑定processor
                .writer(writer)//给step绑定writer
                .faultTolerant()
                .retry(Exception.class)   // 重试
                .noRetry(ParseException.class)
                .retryLimit(1)           //每条记录重试一次
                .skip(Exception.class)
                .skipLimit(200)         //一共允许跳过200次异常
//                .taskExecutor(new SimpleAsyncTaskExecutor()) //设置每个Job通过并发方式执行,一般来讲一个Job就让它串行完成的好
//                .throttleLimit(10)        //并发任务数为 10,默认为4
                .build();
    }
 
Example #2
Source File: LogConfig.java    From SpringBootBucket with MIT License 6 votes vote down vote up
/**
     * step步骤,包含ItemReader,ItemProcessor和ItemWriter
     *
     * @param stepBuilderFactory
     * @param reader
     * @param writer
     * @param processor
     * @return
     */
    @Bean(name = "logStep1")
    public Step logStep1(StepBuilderFactory stepBuilderFactory,
                         @Qualifier("logReader") ItemReader<Log> reader,
                         @Qualifier("logWriter") ItemWriter<Log> writer,
                         @Qualifier("logProcessor") ItemProcessor<Log, Log> processor) {
        return stepBuilderFactory
                .get("logStep1")
                .<Log, Log>chunk(5000)//批处理每次提交5000条数据
                .reader(reader)//给step绑定reader
                .processor(processor)//给step绑定processor
                .writer(writer)//给step绑定writer
                .faultTolerant()
                .retry(Exception.class)   // 重试
                .noRetry(ParseException.class)
                .retryLimit(1)           //每条记录重试一次
                .skip(Exception.class)
                .skipLimit(200)         //一共允许跳过200次异常
//                .taskExecutor(new SimpleAsyncTaskExecutor()) //设置每个Job通过并发方式执行,一般来讲一个Job就让它串行完成的好
//                .throttleLimit(10)        //并发任务数为 10,默认为4
                .build();
    }
 
Example #3
Source File: ComposedTaskRunnerStepFactory.java    From composed-task-runner with Apache License 2.0 6 votes vote down vote up
@Override
public Step getObject() throws Exception {
	TaskLauncherTasklet taskLauncherTasklet = new TaskLauncherTasklet(
			this.taskOperations, taskConfigurer.getTaskExplorer(),
			this.composedTaskProperties, this.taskName, taskProperties);

	taskLauncherTasklet.setArguments(this.arguments);
	taskLauncherTasklet.setProperties(this.taskSpecificProps);

	String stepName = this.taskName;

	return this.steps.get(stepName)
			.tasklet(taskLauncherTasklet)
			.transactionAttribute(getTransactionAttribute())
			.listener(this.composedTaskStepExecutionListener)
			.build();
}
 
Example #4
Source File: AppConfig.java    From SpringBootBucket with MIT License 6 votes vote down vote up
/**
     * step步骤,包含ItemReader,ItemProcessor和ItemWriter
     *
     * @param stepBuilderFactory
     * @param reader
     * @param writer
     * @param processor
     * @return
     */
    @Bean(name = "zappStep1")
    public Step zappStep1(StepBuilderFactory stepBuilderFactory,
                          @Qualifier("appReader") ItemReader<App> reader,
                          @Qualifier("appWriter") ItemWriter<App> writer,
                          @Qualifier("appProcessor") ItemProcessor<App, App> processor) {
        return stepBuilderFactory
                .get("zappStep1")
                .<App, App>chunk(5000)//批处理每次提交5000条数据
                .reader(reader)//给step绑定reader
                .processor(processor)//给step绑定processor
                .writer(writer)//给step绑定writer
                .faultTolerant()
                .retry(Exception.class)   // 重试
                .noRetry(ParseException.class)
                .retryLimit(1)           //每条记录重试一次
                .skip(Exception.class)
                .skipLimit(200)         //一共允许跳过200次异常
//                .taskExecutor(new SimpleAsyncTaskExecutor()) //设置每个Job通过并发方式执行,一般来讲一个Job就让它串行完成的好
//                .throttleLimit(10)        //并发任务数为 10,默认为4
                .build();
    }
 
Example #5
Source File: RestartJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step() {
    return stepBuilderFactory.get("step")
            .<String, String>chunk(2)
            .reader(listItemReader())
            .writer(list -> list.forEach(System.out::println))
            // .allowStartIfComplete(true)
            .startLimit(1)
            .build();
}
 
Example #6
Source File: SplitJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step3() {
    return stepBuilderFactory.get("step3")
            .tasklet((stepContribution, chunkContext) -> {
                System.out.println("执行步骤三操作。。。");
                return RepeatStatus.FINISHED;
            }).build();
}
 
Example #7
Source File: FileItemReaderDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step() {
    return stepBuilderFactory.get("step")
            .<TestData, TestData>chunk(2)
            .reader(fileItemReader())
            .writer(list -> list.forEach(System.out::println))
            .build();
}
 
Example #8
Source File: ComposedRunnerJobFactory.java    From composed-task-runner with Apache License 2.0 5 votes vote down vote up
private void handleTransition(Deque<Flow> resultFlowDeque,
		TaskAppNode taskAppNode) {
	String beanName = getBeanName(taskAppNode);
	Step currentStep = this.context.getBean(beanName, Step.class);
	FlowBuilder<Flow> builder = new FlowBuilder<Flow>(beanName)
			.from(currentStep);

	boolean wildCardPresent = false;

	for (TransitionNode transitionNode : taskAppNode.getTransitions()) {
		String transitionBeanName = getBeanName(transitionNode);

		wildCardPresent = transitionNode.getStatusToCheck().equals(WILD_CARD);

		Step transitionStep = this.context.getBean(transitionBeanName,
				Step.class);
		builder.on(transitionNode.getStatusToCheck()).to(transitionStep)
				.from(currentStep);
	}

	if (wildCardPresent && !resultFlowDeque.isEmpty()) {
		throw new IllegalStateException(
				"Invalid flow following '*' specifier.");
	}
	else {
		//if there are nodes are in the execution Deque.  Make sure that
		//they are processed as a target of the wildcard instead of the
		//whole transition.
		if (!resultFlowDeque.isEmpty()) {
			builder.on(WILD_CARD).to(handleFlowForSegment(resultFlowDeque)).from(currentStep);
		}
	}

	resultFlowDeque.push(builder.end());
}
 
Example #9
Source File: TransactionJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step() {
    DefaultTransactionAttribute attribute = new DefaultTransactionAttribute();
    attribute.setPropagationBehavior(Propagation.REQUIRED.value());
    attribute.setIsolationLevel(Isolation.DEFAULT.value());
    attribute.setTimeout(30);

    return stepBuilderFactory.get("step")
            .<String, String>chunk(2)
            .reader(listItemReader())
            .writer(list -> list.forEach(System.out::println))
            .readerIsTransactionalQueue()
            .transactionAttribute(attribute)
            .build();
}
 
Example #10
Source File: SplitJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step1() {
    return stepBuilderFactory.get("step1")
            .tasklet((stepContribution, chunkContext) -> {
                System.out.println("执行步骤一操作。。。");
                return RepeatStatus.FINISHED;
            }).build();
}
 
Example #11
Source File: JSONFileItemReaderDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step() {
    return stepBuilderFactory.get("step")
            .<TestData, TestData>chunk(2)
            .reader(jsonItemReader())
            .writer(list -> list.forEach(System.out::println))
            .build();
}
 
Example #12
Source File: MultiFileIteamReaderDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step() {
    return stepBuilderFactory.get("step")
            .<TestData, TestData>chunk(2)
            .reader(multiFileItemReader())
            .writer(list -> list.forEach(System.out::println))
            .build();
}
 
Example #13
Source File: DataSourceItemReaderDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step() throws Exception {
    return stepBuilderFactory.get("step")
            .<TestData, TestData>chunk(2)
            .reader(dataSourceItemReader())
            .writer(list -> list.forEach(System.out::println))
            .build();
}
 
Example #14
Source File: StepService0005.java    From seed with Apache License 2.0 5 votes vote down vote up
@Bean
public Step step0005(){
    return stepBuilderFactory.get("step0005")
            .listener(this.settleJobListeners)
            .tasklet(this.nextBizDateTasklet())
            .build();
}
 
Example #15
Source File: XmlFileItemReaderDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step() {
    return stepBuilderFactory.get("step")
            .<TestData, TestData>chunk(2)
            .reader(xmlFileItemReader())
            .writer(list -> list.forEach(System.out::println))
            .build();
}
 
Example #16
Source File: BirthdayMailJobConfig.java    From spring-boot-doma2-sample with Apache License 2.0 5 votes vote down vote up
@Bean
public Step birthdayMailStep() {
    return stepBuilderFactory.get("birthdayMailStep").listener(new DefaultStepExecutionListener())
            .<User, SendMailQueue>chunk(100).reader(birthdayMailUserItemReader()).processor(birthdayMailProcessor())
            .writer(birthdayMailItemWriter()).taskExecutor(taskExecutor)
            // 2つのスレッドで処理するサンプル
            .throttleLimit(2).build();

}
 
Example #17
Source File: CompositeJobExecutionListenerJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step() {
    return stepBuilderFactory.get("step")
            .tasklet((contribution, chunkContext) -> {
                System.out.println("执行步骤....");
                return RepeatStatus.FINISHED;
            }).build();
}
 
Example #18
Source File: SplitJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step2() {
    return stepBuilderFactory.get("step2")
            .tasklet((stepContribution, chunkContext) -> {
                System.out.println("执行步骤二操作。。。");
                return RepeatStatus.FINISHED;
            }).build();
}
 
Example #19
Source File: ComposedRunnerVisitorConfiguration.java    From composed-task-runner with Apache License 2.0 5 votes vote down vote up
private Step createTaskletStep(final String taskName) {
	return this.steps.get(taskName)
			.tasklet(new Tasklet() {
				@Override
				public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) throws Exception {
					return RepeatStatus.FINISHED;
				}
			})
			.transactionAttribute(getTransactionAttribute())
			.build();
}
 
Example #20
Source File: FlowJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step3() {
    return stepBuilderFactory.get("step3")
            .tasklet((stepContribution, chunkContext) -> {
                System.out.println("执行步骤三操作。。。");
                return RepeatStatus.FINISHED;
            }).build();
}
 
Example #21
Source File: FlowJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step2() {
    return stepBuilderFactory.get("step2")
            .tasklet((stepContribution, chunkContext) -> {
                System.out.println("执行步骤二操作。。。");
                return RepeatStatus.FINISHED;
            }).build();
}
 
Example #22
Source File: FlowJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step1() {
    return stepBuilderFactory.get("step1")
            .tasklet((stepContribution, chunkContext) -> {
                System.out.println("执行步骤一操作。。。");
                return RepeatStatus.FINISHED;
            }).build();
}
 
Example #23
Source File: NestedJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step childJobTwoStep() {
    return new JobStepBuilder(new StepBuilder("childJobTwoStep"))
            .job(childJobTwo())
            .launcher(jobLauncher)
            .repository(jobRepository)
            .transactionManager(platformTransactionManager)
            .build();
}
 
Example #24
Source File: NestedJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step childJobOneStep() {
    return new JobStepBuilder(new StepBuilder("childJobOneStep"))
            .job(childJobOne())
            .launcher(jobLauncher)
            .repository(jobRepository)
            .transactionManager(platformTransactionManager)
            .build();
}
 
Example #25
Source File: BatchConfig.java    From Spring-5.0-Cookbook with MIT License 5 votes vote down vote up
@Bean
public Step chunkStep() {
    return stepCreators.get("chunkStep")
        .<Department, Department>chunk(5)
        .reader(reader())
        .processor(processor())
        .writer(writer())
        .build();
}
 
Example #26
Source File: DeciderJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step3() {
    return stepBuilderFactory.get("step3")
            .tasklet((stepContribution, chunkContext) -> {
                System.out.println("执行步骤三操作。。。");
                return RepeatStatus.FINISHED;
            }).build();
}
 
Example #27
Source File: DeciderJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step2() {
    return stepBuilderFactory.get("step2")
            .tasklet((stepContribution, chunkContext) -> {
                System.out.println("执行步骤二操作。。。");
                return RepeatStatus.FINISHED;
            }).build();
}
 
Example #28
Source File: DeciderJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step1() {
    return stepBuilderFactory.get("step1")
            .tasklet((stepContribution, chunkContext) -> {
                System.out.println("执行步骤一操作。。。");
                return RepeatStatus.FINISHED;
            }).build();
}
 
Example #29
Source File: MultiStepJobDemo.java    From SpringAll with MIT License 5 votes vote down vote up
private Step step2() {
    return stepBuilderFactory.get("step2")
            .tasklet((stepContribution, chunkContext) -> {
                System.out.println("执行步骤二操作。。。");
                return RepeatStatus.FINISHED;
            }).build();
}
 
Example #30
Source File: CustomerReportJobConfig.java    From spring-batch-article with MIT License 5 votes vote down vote up
@Bean
public Step chunkStep() {
    return stepBuilders.get("chunkStep")
        .<Customer, Customer>chunk(20)
        .reader(reader())
        .processor(processor())
        .writer(writer())
        .build();
}