This is a small project to understand the role of optimistic and pessimistic locking in dealing with highly concurrent systems.
Medium Article Link
It explains the Concurrency Control With Optimistic and Pessimistic Locking
Run mvn clean install -s settings.xml
-
PurchaseOrder.java class has the logic for optimistic and pessimistic locking
-
SqlLockingApplicationTests.java contains all the testcases.
test_failureScenario
demonstrates The Lost Update anomaly.test_OptimisticLockingScenario
demonstrates the solution using optimistic locking.test_PessimisticLockingScenario
demonstrates the solution using pessimistic locking.
-
StockRepository.java has different update statements fired for various locking scenarios.