lundi 1 décembre 2014

Lock data in DB while external API call is pending?


I have an interesting situation, and I am looking for the best way to solve it. My app runs like this:


1) The user gets a Promotion Pin from Some Company, and I have a db table with these pins also. The user submits my form to recieve a reward.


2) I first check if the pin is valid/non-expired using a basic stored procedure.


3) I contact a third party API to send them the reward.


4) I retire the pin using a basic stored procedure.


My issue is, how do I guarantee that the pin is not reused again while the API call is pending. I know this is a split second operation, but I would rather remove this possibility.





Aucun commentaire:

Enregistrer un commentaire