I am trying to build a movie ticketing system. But I am not able to figure out how to solve the below use case:
Let’s say there are 10 seats namely S1,S2,S3,S4… S10.
Now let’s say that User1 had logged into the system and selected seats S1 and S2.
Both these seats must be automatically blocked for a time span of 15minutes; so that the User1 can make payment within this time and confirm the seats.
Meanwhile if another User2 logs into the system, the seats S1 and S2 must be viewed as blocked.
The seats will be unblocked only if the 15minutes time out occurs (or) The User1 willingly aborts the booking process.
Any idea how to achieve this? Can we do this blocking and unblocking asynchronously by avoiding page reloading?
I have already searched for solutions and found this related question: How do I handle the potential concurrency problem of making a payment to Paypal for a limited number of items?
But it didn't help me. I am sure I have to take the item off the shelf for sometime. But technically how to achieve this? should i update the database to make that seat as blocked? if i did so, how to unblock it upon failure or if the user abandons the system? How to update the UI asynchronously ?