[英]Can I run long tasks in a Spring Boot application?
I have a Spring Boot application, which shows some data from MongoDB on an AngularJS page and allows the user to change it. 我有一个Spring Boot应用程序,它在AngularJS页面上显示来自MongoDB的一些数据,并允许用户更改它。
Now I need to create a mechanism, which allows me to 现在我需要创建一个允许我的机制
Can I implement this in scope of the Spring Boot application? 我可以在Spring Boot应用程序的范围内实现它吗? If yes, what parts of Spring can I use to do that?
如果是的话,我可以使用Spring的哪些部分来做到这一点?
I would argue that it's not good idea to embed batch processing into your service exposing MongoDB data store. 我认为将批处理嵌入到暴露MongoDB数据存储的服务中并不是一个好主意 。
I would create separate batch application . 我会创建单独的批处理应用程序 Spring Batch would be natural choice if you are using Spring stack.
如果您使用Spring堆栈, Spring Batch将是自然的选择 。 You would need to figure out how you want to host Spring Batch job and how you want to trigger and schedule it.
您需要弄清楚如何托管Spring Batch作业以及如何触发和计划它。 Spring Batch needs SQL storage for it's metadata .
Spring Batch需要SQL存储才能获得元数据 。
Status of the batch processing could be monitored by one other application with Spring Batch Admin module running on Servlet container . 可以通过在Servlet容器上运行Spring Batch Admin模块的另一个应用程序监视批处理的状态。 If you point this application to SQL storage of Spring Batch job application, you get monitoring of status via web UI out of the box .
如果将此应用程序指向Spring Batch作业应用程序的SQL存储,则可以通过Web UI立即监视状态 。
Of course it could run each app with Spring Boot. 当然它可以使用Spring Boot运行每个应用程序。
If you don't want to handle this operational complexity it brings to host there three applications, yous still can all three embed into one and it would work fine with Spring Boot . 如果你不想处理这种操作复杂性,它会带来三个应用程序,你们仍然可以将它们全部嵌入到一个应用程序中, 它可以在Spring Boot中正常工作 。 You could even execute jobs with parameters manually or restart them via Spring Batch Admin configured to have access to Spring Batch Job beans.
您甚至可以手动执行带参数的作业,也可以通过配置为可以访问Spring Batch Job bean的Spring Batch Admin重新启动它们。
You could also explore using MongoDb as storage for Spring Batch metadata. 您还可以使用MongoDb作为Spring Batch元数据的存储进行探索。 Eg this project may help .
例如,该项目可能有所帮助 But such mechanism would need to be used by Spring Batch application and also by Spring Batch Admin module visualizing status of processing.
但是这种机制需要由Spring Batch应用程序使用,也需要Spring Batch Admin模块可视化处理状态。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.