java - 通过计划任务进行批量操作的正确方法?

标签 java spring hibernate scheduled-tasks bulk

在我的应用程序中,我有一组计划任务,用于处理所有用户的数据并执行各种任务,例如收入、税务计算、为所有用户生成报表。由于这些进程需要为每个用户运行,因此由于用户数量较多,它们需要花费大量时间(许多小时)。一个用户的数据处理完全独立于另一用户的数据处理,因此它们可以并行运行。我在这里有什么选择?进行此类大型/批量操作的最佳实践是什么? 我们使用带有 spring、jpa 和 hibernate 的 J2SE 平台。

最佳答案

您应该通过批处理执行相同的操作。

既然您提到您正在使用 Spring 进行操作,您可以考虑使用 Spring Batch

Spring Batch provides reusable functions that are essential in processing large volumes of records, including logging/tracing, transaction management, job processing statistics, job restart, skip, and resource management. It also provides more advanced technical services and features that will enable extremely high-volume and high performance batch jobs through optimization and partitioning techniques.

查看 Reference manual以及如何实现。

关于java - 通过计划任务进行批量操作的正确方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14036956/

相关文章:

java - 一个 web.xml 中的两个 DispatherServlet

java - 为什么 Hibernate 尝试插入具有已存在 id 的新记录?

java - 传递字节数组出现越界错误,但它通过了 junit 测试

java - Spring Boot cron 表达式问题 - 禁用启动时运行

spring - 模拟 CGLIB 代理服务的属性不起作用

java - Hibernate Search - 在给定范围内搜索

java - java.sql.Blob 基本属性的问题

java - 忽略调试库中的 java 代码

java - 为什么我不能在 Java NatTable 中使用特定的 CellEditor 实现 CellEditorMouseEventMatcher?

java - 高效的条件查询仅选择查询的第一个和最后一个结果?