4
votes

I'm using the Spring Batch (2.2.6.RELEASE) FlowBuilder.SplitBuilder to declare a flow in a Java Config class, which executes 3 subflows in parallel:

@Bean
public SimpleFlow mainFlow() {
    return new FlowBuilder<SimpleFlow>("Main Flow")
            .start(flow1())
            .split(new SimpleAsyncTaskExecutor())
            .add(flow2(), flow3())
            .build();
}

This syntax comes from spring-batch FlowBuilder.SplitBuilder javadoc.

But then, flow1 is never executed; only flow2 and flow3 are executed.

It looks like a bug to me... What do you think?

A junit test can be found in class ParallelFlowsJobConfigTest on this github repository: https://github.com/galak75/spring-batch-labs

2
Seems to be related to a newly resolved BATCH-2346 issue. I'll have to run my tests with Spring Batch 3.0.4 release. - Géraud
Spring Batch 3.0.4 is not yet released so far. - Géraud

2 Answers

2
votes

This worked for me:

@Bean
public SimpleFlow mainFlow() {
    SimpleFlow splitFlow = new FlowBuilder<SimpleFlow>("Split Flow")
        .split(new SimpleAsyncTaskExecutor())
        .add(flow2(), flow3())
        .build();
    return new FlowBuilder<SimpleFlow>("Main Flow")
        .start(flow1())
        .next(splitFlow)
        .end();
}

The important detail is the "next(...)" and the fact that slit should be in its own sub-flow.

1
votes

Resolved by BATCH-2346, delivered in Spring Batch 3.0.4 release.