user373201
user373201

Reputation: 11435

spring batch run a task only once for ever

I have a spring batch job. The first task in the job is to create dummy data. I want to run this job only once, it does not matter how many times the job is run after that or let say be able to configure this task to run only once based on some property value in properties file. How do i achieve this functionality.

In production system, this could be same as creating the folder structures to copy different file types before processing the files.

Upvotes: 1

Views: 3556

Answers (1)

Serkan Arıkuşu
Serkan Arıkuşu

Reputation: 5619

Tasklet interface of Spring Batch is what you are looking for. You must implement the execute method.

public class FolderTasklet implements Tasklet{

    public RepeatStatus execute(StepContribution stepContribution, ChunkContext chunkContext) throws Exception {
    //your copy folder structure logic goes here
    }
}

Upvotes: 1

Related Questions