Reputation: 978
I am working on a springboot application, and I have to manage a particular use case.
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.
This order will be stored in a database, and used in Springboot for aggregations on an upper level of the application.
@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.
This two orders will be used to compute a final amount, so the final amount is 700.
Let's assume, that we change the first order from 500 -> 1000.
The first idea was to use getOne(id)
+ save
to update.
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 ?
Please let me know, if you need more details !
Thanks in advance for your help
Upvotes: 1
Views: 148
Reputation: 3400
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
Upvotes: 1