[英]How to manage updates in a springboot application
I am working on a springboot application, and I have to manage a particular use case.我正在开发一个 springboot 应用程序,我必须管理一个特定的用例。
Assume that we have a pipeline, where an an order containing an id and an amount is consumed by a kafka topic from IBM/AS400.假设我们有一个管道,其中包含一个 id 和一个数量的订单被来自 IBM/AS400 的 kafka 主题消费。
This order will be stored in a database, and used in Springboot for aggregations on an upper level of the application.此订单将存储在数据库中,并在 Springboot 中用于应用程序上层的聚合。
@Data
@NoArgsConstructor
@AllArgsConstructor
public class Order implements Serializable {
private string id;
private String amount;
}
Let's assume that we have 2 orders, one with an amount of 500 and another one with an amount of 200.假设我们有 2 个订单,一个金额为 500,另一个金额为 200。
This two orders will be used to compute a final amount, so the final amount is 700.这两个订单将用于计算最终金额,因此最终金额为 700。
Let's assume, that we change the first order from 500 -> 1000.假设我们将第一个订单从 500 -> 1000 更改。
The first idea was to use getOne(id)
+ save
to update.第一个想法是使用
getOne(id)
+ save
来更新。
So it would be:所以它会是:
String newAmount = OrderRepository.getOne(1);
orderToUpdate.setAmount(newAmount);
orderRepository.save(orderToUpdate);
Since the order is used on an upper level of the application, and that updating this order will do a computation using 10 years of history, which will take a long time, Is there any way to solve this issue?由于订单是在应用程序的上层使用的,更新这个订单会使用10年的历史计算,需要很长时间,请问有什么办法可以解决这个问题吗?
Please let me know, if you need more details !如果您需要更多详细信息,请告诉我!
Thanks in advance for your help在此先感谢您的帮助
If you want to remove the aggregation completely, and I don't know how many times in a day aggregation happens, you could do the following如果您想完全删除聚合,并且我不知道一天聚合发生多少次,您可以执行以下操作
Assumptions假设
Steps脚步
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.