1

With classic java multithreaded execution, the parallelized execution can be proved easily (see: SO: Java Thread Example) by calling

this.getId()

which results in a System.output.println():

[ID 9]
[ID 10]
[ID 8]

How can I prove that parallel execution really happens in Java Spring Batch/Spring Boot?

Community
  • 1
  • 1

2 Answers2

1

Like the documentation describes you can configure jobs and steps.

To see which job or step is currently running you will give both a name.

@Configuration
@EnableBatchProcessing
@EnableAutoConfiguration
public class BatchConfiguration {

  @Autowired
  private JobBuilderFactory jobBuilderFactory;

  @Autowired
  private StepBuilderFactory stepBuilderFactory;

  @Bean
  public Step step1() {
    return stepBuilderFactory.get("step1")
        .tasklet(new Tasklet() {
          public RepeatStatus execute(StepContribution contribution, ChunkContext chunkContext) {
            return null;
          }
        })
        .build();
  }

  @Bean
  public Job job(Step step1) throws Exception {
    return jobBuilderFactory.get("job1")
        .incrementer(new RunIdIncrementer())
        .start(step1)
        .build();
  }
}

And JobExecution has many information about your job.

Here some useful docs:

Patrick
  • 12,336
  • 15
  • 73
  • 115
0

a very generic way would be:

    Thread thread = Thread.currentThread();
    System.out.println(thread);