nogamsung
When the same request hits several servers: a Redisson distributed lock behind one annotation

When the same request hits several servers: a Redisson distributed lock behind one annotation

With more than one server, synchronized can't prevent concurrency problems. We already had Redis, so I picked a Redisson distributed lock and wrapped it in a custom @RedissonLock annotation and an AOP aspect that handle the SpEL key, waitTime and leaseTime. This covers that build, what to watch for around failed lock acquisition and transaction ordering, and a concurrency test with three threads.