0
votes

I am using spring batch where step 1 is reading from database writing into list then have step2 read from list from reader and process and write to database and step 3 will read from list, process and write into database.

Step1Reader(read from Database)+---> ItemProcessor#1 ---> ItemWriter#1

Step2Reader(read from step1)+---> ItemProcessor#1 ---> ItemWriter#1

Step3Reader(read from step1)---> ItemProcessor#2 ---> ItemWriter#2

How can implement this?

1
What have you tried? Are you familiar with selecting data from a Repository in spring?Stephan
No I have no tried repository. I m thinking to use custom repository. As we are going to use criteria query and @query.jinaljoshi

1 Answers

2
votes

Really nothing fancy.

    public Job job() {
        JobBuilder builder = new JobBuilder("load job").repository(jobRepository);
        return builder
                .start(stepCheckFeedDate())
                .next(stepUpdateControlStart())
                .next(stepUnload())
                .next(loadFeedDataToDbStep())
                .next(setpArchiveTask())
                .next(stepUpdateControlComplete())
                .build();
    }

You can add many steps as you wish.