question

arunksi avatar image
arunksi asked arunksi commented

Replicate Orders

We have a use-case where we need to replicate the orders for a merchant in run-time in our database. We plan to use a combination of orderId and modifiedTime(of the order) to keep track of the changes in the order. We have thought of an approach mentioned below. Please provide your feedback in this approach and suggest any better approach you may think of.

So, our primary key will be orderId,modifiedTime for which we will store all the details of the order. We will keep on polling orders on a regular basis. If we find that for an existing order we have higher modifiedTime timeStamp then we will delete the existing order details and insert the new order details.

Orders
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Jeffrey Blattman avatar image
Jeffrey Blattman answered arunksi commented

Have you experimented with filters? You could use the modifiedTime filter to fetch all the modified orders for a particular merchant in one shot.

2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

arunksi avatar image arunksi commented ·

The use case which won't be fulfilled by your approach is when we want to query a given order in a previous timestamp which got missed the first time we tried to pull in the records. How will we guarantee idempotency in that case?

0 Likes 0 ·
Jeffrey Blattman avatar image Jeffrey Blattman ♦♦ commented ·

You know if you "miss" an order or not. You have the ability to track that and make decisions based on it, right? I don't think polling is going to be reasonable when you think about scaling. Imagine tens of thousands of devices polling millions of orders? Perhaps you aren't worried about that sort of scaling at this point, but something to keep in mind.

0 Likes 0 ·

Welcome to the
Clover Developer Community