Class FlowBuilder.SplitBuilder<Q>

java.lang.Object
org.springframework.batch.core.job.builder.FlowBuilder.SplitBuilder<Q>
Type Parameters:
Q - the result of the parent builder's build()
Enclosing class:
FlowBuilder<Q>

public static class FlowBuilder.SplitBuilder<Q> extends Object
A builder for building a split state. Example (builder is a FlowBuilder):
 Flow splitFlow = builder.start(flow1).split(new SyncTaskExecutor()).add(flow2).build();
 
where flow1 and flow2 will be executed (one after the other because of the task executor that was added). Another example
 Flow splitFlow = builder.start(step1).split(new SimpleAsyncTaskExecutor()).add(flow).build();
 
In this example, a flow consisting of step1 will be executed in parallel with flow.

Note: Adding a split to a chain of states is not supported. For example, the following configuration is not supported. Instead, the configuration would need to create a flow3 that was the split flow and assemble them separately.

 // instead of this
 Flow complexFlow = new FlowBuilder<SimpleFlow>("ComplexParallelFlow")
                       .start(flow1)
                       .next(flow2)
                       .split(new SimpleAsyncTaskExecutor())
                       .add(flow3, flow4)
                       .build();

 // do this
 Flow splitFlow = new FlowBuilder<SimpleFlow>("parallelFlow")
                       .start(flow3)
                       .split(new SimpleAsyncTaskExecutor())
                       .add(flow4).build();

 Flow complexFlow = new FlowBuilder<SimpleFlow>("ComplexParallelFlow")
                       .start(flow1)
                       .next(flow2)
                       .next(splitFlow)
                       .build();
 
Author:
Dave Syer, Michael Minella
  • Constructor Details

    • SplitBuilder

      public SplitBuilder(FlowBuilder<Q> parent, org.springframework.core.task.TaskExecutor executor)
      Parameters:
      parent - the parent builder
      executor - the task executor to use in the split
  • Method Details

    • add

      public FlowBuilder<Q> add(Flow... flows)
      Add flows to the split, in addition to the current state already present in the parent builder.
      Parameters:
      flows - more flows to add to the split
      Returns:
      the parent builder