Here is a description of a problem that I am facing right now
- I want to give user some promotion based on whether he has done a transaction in which he has been given a promotional discount
- Promotional discount is some percent off on the transaction
- So the condition is, before processing transactions, it will be checked whether he as done a transaction using a promotion or not, and based on that amount will be calculated.
Problem is if two request comes at the same time and reads that a transaction has not been done, and on both the transaction promotion is applied.
Found a solution, https://dzone.com/articles/synchronized-by-the-value-of-the-object-in-java, but not valid for distributed environment.
What are can be different ways to solve such a program. Was just very curious on this problem >