Why spring batch application remembers previously processed file after restart?

Viewed 161

I have one weird problem in spring batch boot (1.5.8.RELEASE) based application. This job triggers on incoming file and everything works good. But when I restart my application, It remembers last processed file name even if there is no file in the incoming directory! And job kicks off and course errors out because file is not there. And worse is another job in same application which has JPA reader, that also triggers similarly and remembers all the data of previous run and re-processes it ! Not finding any solution on internet. These are the job configurations

    @Bean
public Job cardActivationJob() {
    return jobBuilderFactory.get("fundingCardActivationJob")
            .incrementer(new RunIdIncrementer())
            .flow(fileDbFinderStep())
            .next(fundingCardActivationStep())
            .next(fileRenamingStep())
            .next(readNotificationDataStep())
            .end().listener(thisJobExecutionListener())
            .build();
}

@Bean
public Step cardActivationStep() {
    return stepBuilderFactory.get("fundingCardActivationStep")
            .<FundingCardActivationVo, FundingCardActivationVo>chunk(1)
            .reader(reader)
            .processor(processor)
            .writer(writer)
            .build();
}

JPA reader job

    @Bean
public Job cardActivationJob2() {
    return jobBuilderFactory.get("jpmcFundingCardActivationJob")
            .incrementer(new RunIdIncrementer())
            .flow(jpmcFndingCardActivationStep())
            .end().listener(thisJobExecutionListener())
            .build();
}

@Bean
public Step cardActivationStep2() {
    return stepBuilderFactory.get("jpmcFundingCardActivationStep")
            .<FundingCardActivationVo, FundingCardActivationVo>chunk(1)
            .reader(scheduledItemReader)
            .processor(processor)
            .writer(writer)
            .build();
}
0 Answers
Related