Hi,

I am in the process of writing a webapp that allows users to make a payment and register for a course. Using Apache -- Tomcat --- MySQL.

The question is a design question i guess, unless there is something in Tomcat that I can leverage, which i might not know. I know that this is a design question , but since I am using Tomcat as my JSP/Servlet container and since the participants here are experts in this field , I thought that I might get some good pointers here.

Lets take this scenario:

User 1 and User 2 are trying to register for a course called "Taekwando". The fee for registering is X amount. Also there is another course called "Majagutamba" and it costs Y amount. Both theses courses have exactly 1 seat remaining.

Now lets say user 1 adds both these courses in his shopping cart, and user 2 does the same, since user 1 has not completed his transaction and paid the enrollment table wont have an entry for user1. (The Enrollment table keeps track of which user is enrolled in which course). Therefore both users have both those courses in their shopping carts. Now both of them proceed to checkout. They enter their credit card information and say submit. Both those users make payments and get enrolled for both those courses!!! Which is wrong , since both those courses could only enroll 1 more person, instead two new users were just added.

To avoid the above problem one could implement a singleton synchronized Transaction object that would process shopping cart checkout in a queue. The problem with this approach are:
1. If anything goes wrong with any one transaction, it would hold up the entire queue. (Well we can have some sort of timeouts and take care of that.)
2. Since this is a syncrhonized singleton and if the traffic for registering for the courses is high, this would be a slow process for which the user will have to wait.


Is there a better solution, algorithm, to do this ? Any help is appreciated.

Thanks,


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to