Spring batch or Spring boot async method execution?

回眸只為那壹抹淺笑 提交于 2019-12-24 14:53:01

问题


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


回答1:


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




回答2:


If there are large amounts of services should be executed, spring-batch would be the choice. Otherwise, I guess there is no need to import spring-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, cause spring-batch are professional in this.



来源:https://stackoverflow.com/questions/36675656/spring-batch-or-spring-boot-async-method-execution

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!