What is the difference between Multi-threaded Step and Local Partitioning in spring batch?

August 13, 2019, at 10:40 PM

I've the following doc.

And there are mentioned that:

1.1. Multi-threaded Step The simplest way to start parallel processing is to add a TaskExecutor to your Step configuration.

When using java configuration, a TaskExecutor can be added to the step as shown in the following example:

public TaskExecutor taskExecutor(){
    return new SimpleAsyncTaskExecutor("spring_batch");
public Step sampleStep(TaskExecutor taskExecutor) {
        return this.stepBuilderFactory.get("sampleStep")
                                .<String, String>chunk(10)

The result of the above configuration is that the Step executes by reading, processing, and writing each chunk of items (each commit interval) in a separate thread of execution. Note that this means there is no fixed order for the items to be processed, and a chunk might contain items that are non-consecutive compared to the single-threaded case. In addition to any limits placed by the task executor (such as whether it is backed by a thread pool), there is a throttle limit in the tasklet configuration which defaults to 4. You may need to increase this to ensure that a thread pool is fully utilized.

But before I thought that it should be achieved by local partitioning and I should provide a partitioner which say how to divide data into pieces. Multi-threaded Step should do it automatically.


Could you explain how does it work ? How can I manage it besides the thread number? Will it work for flat file?


I created the example:

public class MultithreadedStepConfig {
    public JobBuilderFactory jobBuilderFactory;
    public StepBuilderFactory stepBuilderFactory;
    private ToLowerCasePersonProcessor toLowerCasePersonProcessor;
    private DbPersonWriter dbPersonWriter;
    Resource resources;
    public Job job(Step databaseToDataBaseLowercaseSlaveStep) {
        return jobBuilderFactory.get("myMultiThreadedJob")
                .incrementer(new RunIdIncrementer())
    private Step csvToDataBaseSlaveStep() {
        return stepBuilderFactory.get("csvToDatabaseStep")
                .<Person, Person>chunk(50)
    public FlatFileItemReader csvPersonReaderMulti() {
        return new FlatFileItemReaderBuilder()
                .names(new String[]{"firstName", "lastName"})
                .fieldSetMapper(new BeanWrapperFieldSetMapper<Person>() {{
    public TaskExecutor jobTaskExecutorMultiThreaded() {
        ThreadPoolTaskExecutor taskExecutor = new ThreadPoolTaskExecutor();
        // there are 21 sites currently hence we have 21 threads
        return taskExecutor;

And it really works according the log but I want to know details. Is it better than self written partitioner ?

JavaFX : StackPane Sequential Transition

JavaFX : StackPane Sequential Transition

I am trying to switch between 3 different AnchorPane (on click of a Button) with a FadeTransition and below is my code,

How can I convert this code to prepared-statement or statement in jdbc? [on hold]

How can I convert this code to prepared-statement or statement in jdbc? [on hold]

I'm trying to insert this values to a new table but eclipse doesn't read this query:

Taking multiple lines with multiple inputs in each Lines

Taking multiple lines with multiple inputs in each Lines

My requirement is to take multiple inputs from user on multiple lines