Configuring Spring Batch Steps in Parallel (Split) using Annotations

给你一囗甜甜゛ 提交于 2019-12-06 07:35:31

The SimpleJobBuilder provides facilities for configuring a split via java config. Below is an example taken from the FlowJobBuilderTests (https://github.com/spring-projects/spring-batch/blob/master/spring-batch-core/src/test/java/org/springframework/batch/core/job/builder/FlowJobBuilderTests.java). Obviously you'll want to break this up a bit, but it should illustrate the general idea.

// Create each flow
Flow flow = new FlowBuilder<Flow>("subflow").from(step1).end();

// Create the job
SimpleJobBuilder builder = new JobBuilder("flow").repository(jobRepository).start(step2);

// Create split providing an async task executor so the flows are executed in parallel
builder.split(new SimpleAsyncTaskExecutor()).add(flow).end();

// Build the job and execute it
builder.preventRestart().build().execute(execution);
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!