membersound
membersound

Reputation: 86757

How to create a async step in spring-batch?

I have an existing spring-batch Step and would like to refactor it with Async processor + writer.

StepBuilderFactory steps;
steps.get("test").chunk(1000)
        .reader(new FlatFileItemReader<String>())
        .processor(new AsyncItemProcessor<String, String>())
        .writer(new AsyncItemWriter<String>())
        .build();

This does not work and complains for the processor:

The method processor(ItemProcessor<? super Object,? extends Object>) in the type SimpleStepBuilder<Object,Object> is not applicable for the arguments (AsyncItemProcessor<String,String>).

How is a step to be build using async?

Upvotes: 2

Views: 2334

Answers (1)

Palcente
Palcente

Reputation: 635

You need to wrap the output of the processor into java.util.concurrent.Future for AsyncItemProcessor.

API

Upvotes: 2

Related Questions