Spring批处理或Spring引导异步方法执行? [英] Spring batch or Spring boot async method execution?

查看:35
本文介绍了Spring批处理或Spring引导异步方法执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一种情况,要从 4 个不同的 Web 服务读取数据,对其进行处理,然后将结果存储在数据库表中.此任务完成后也发送通知.此过程的触发器是通过 Web 服务调用.我应该将我的工作编写为 spring 批处理作业,还是将整个读取/处理代码编写为从 Rest Controller 调用的异步方法(使用 @Async)?

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?

请推荐

推荐答案

在我看来,你的选择应该是@Async,因为 Spring Batch 是为大数据处理而设计的,它不考虑按需处理,通常你创建您的批次,然后按计划启动该批次.这种架构的好处将是你的工作的可靠性,在失败等情况下,colud 重新启动.在您的情况下,您有数据集成问题,我建议您查看 Spring Integration.您可以拥有一个通过休息调用启动的 Spring 集成管道.

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.

希望能帮到你

这篇关于Spring批处理或Spring引导异步方法执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆