Using ASP.NET Core background service without overlapping execution

61 views Asked by At

I have a controller I built that basically pulls in shopify orders and checks to see if they are in another sites woocommerce database and if not it adds the order. There are about 200 orders coming in every few hours. Shopify offers webhooks which I could trigger this endpoint to add the new order but I wasnt sure if I wanted to rely on webhooks rather than just run a background service every hour or so and just updated it then using a schedule. I have not been able to find a good example of how I can run a background service but ensure if the previous process is done before running it again. I do not want it to ever overlap or I could have data issues. Say I wanted to set the timer at 15 minutes and for some reason there is a surge of orders and this procedure takes longer than 15 minutes well I wouldnt want that same procedure to start again while the other is going.

How would one implement such a architecture in asp.net core 7 with minimal api?

0

There are 0 answers