Elias
Elias

Reputation: 81

Multiple instances of the same spring batch job running in each thread with different params

Using spring batch/spring boot, is it possible to have a spring batch job with reader, processor, and writer being started as a job multiple times per thread with different jobparameters?

My use case:

I have a number of various folders that I need to watch. If new files enters a folder I need to invoke the job and lock the folder while job is processing.

So this can happen for a various number of folders so that's why I need the multiple instances of a spring batch job but with different jobparameters each time.

One job instance per folder and the number of folders can vary. Anyone know if its even possible with spring batch, or should invent it myself? I tried with spring batch job but it's always saying:

A job execution for this job is already running: JobInstance: id=1, version=0, Job=[feedfiletransformer-delegate-job]

Upvotes: 0

Views: 2272

Answers (1)

Elias
Elias

Reputation: 81

Solved by reading this post mkyoung

JobParameters jobParameters = 
          new JobParametersBuilder()
          .addLong("time",System.currentTimeMillis()).toJobParameters();

Upvotes: 1

Related Questions