fernando1979
fernando1979

Reputation: 1947

Use Spring batch for not scheduled process?

I have had experience working with Spring Batch a few months but I have got a doubt a few days ago. I have to process a file and then update a database from it but this is not a scheduled batch process because it has to be executed just once.

  1. Is Spring batch recommended to execute not scheduled processes like this one? Or the fact that is not scheduled has nothing to do with using Spring batch or not

Thanks

Upvotes: 0

Views: 361

Answers (1)

Mahmoud Ben Hassine
Mahmoud Ben Hassine

Reputation: 31600

Is Spring batch recommended to execute not scheduled processes like this one? Or the fact that is not scheduled has nothing to do with using Spring batch or not

Yes, the fact that your job has to be executed only once has nothing to do with using Spring Batch or not. There is a difference between developing the job (using Spring Batch or not) and scheduling the job (using cron, quartz, etc).

For your use case (process a file and then update a database), I would recommend using Spring Batch to develop your job. Then, you can choose to run it:

  • only once or on demand (Spring Batch provides APIs to run the job)
  • or schedule it to run repeatedly using your favourite scheduler

Upvotes: 1

Related Questions