jinaljoshi
jinaljoshi

Reputation: 31

Read from database write into list. Read that list and use into another steps in spring batch

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?

Upvotes: 0

Views: 469

Answers (1)

Qingfei Yuan
Qingfei Yuan

Reputation: 1212

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.

Upvotes: 2

Related Questions