I have a situation where the data is to be read from 4 different web services, process it and then store the results in a database table. Also send a notification after this task is complete. The trigger for this process is through a web service call. Should I write my job as a spring batch job or write the whole read/process code as an async method (using @Async) which is called from the Rest Controller?
Kindly suggest
If there are large amounts of services should be executed,
spring-batch
would be the choice. Otherwise, I guess there is no need to importspring-batch
.In my opinion,
@Async
annotation is the easier way.If both methods can work, of course simpler the better.
At the end, if there will be more and more
service
not only 4,spring-batch
would be the better solution, causespring-batch
are professional in this.In my opinion the your choice should be @Async, because Spring Batch was designed for large data processing and it isn't thought to processing on demand, typically you create a your batch and then launch the batch with a schedule. The benefit of this kind of architetture will be the reliability of your job that colud restarted in case of fail and so on. In your case you have a data integration problem and I can suggest to see at Spring Integration. You could have a Spring Integration pipeline that you start through a rest call.
I hope that this can help you