I have a business logic already developed in spring boot that needs to be run once in every 60 days. I'm little confused on whether convert it to spring batch or use scheduler annotation. What all factors should I consider to assess the same? Does either of them has any performance upper-hand over the other? I'm new to the scheduler-batch concept and this is my first time work on the same.
1 Answers
How to assess whether to use spring batch or scheduler in application?
Spring Batch is not a scheduler, so it's not an either or question. You can use both, for example use a scheduler to schedule a Spring Batch job to run at a given time.
The question you should be asking is: is it worth transforming the business logic you already developed in spring boot in a Spring Batch job to benefit from what Spring Batch offers (the whole app could remain a boot app).
As a side note, since your job needs to be run every 60 days, using @Scheduled
means you would have a JVM running for two months to run a job. Unless you are planning to use the same JVM for other things in the meantime, this would be an inefficient use of resources. Other scheduling mechanisms like cron
is more appropriate in this case.

- 28,519
- 3
- 32
- 50
-
Perfect! Thanks for making my understanding so clear. I think this makes life easier for me, I need not disturb my existing springboot app. so in order to trigger the appliation run every 60 days, I can just use crontab instead, right? – Siena Oct 02 '20 at 09:38
-
1I think crontab is more appropriate for such a schedule. Now if you use your JVM to schedule other things in the meantime and you prefer to use `@Scheduled`, then it could be fine as well. It's up to you to choose the right approach. Please accept the answer if it helped. Thank you. – Mahmoud Ben Hassine Oct 02 '20 at 12:13