Distributed Lock in Spring Boot

288 Views Asked by At

I have a Spring Boot service with multiple instances. I have some job running named A. If another request comes to run the job A, while it's still running I don't want it to trigger another invocation. I need distributed lock for this. Now my service was already connecting to Redis using jedis, but jedis doesn't have any locking primitives supported by default. I tried to use Spring Integration Redis' RedisLockRegistry but it doesn't support custom TTL at lock level(https://github.com/spring-projects/spring-integration/issues/3444). Redis official docs mention Redisson as the only java client available under Distributed Locks section(https://redis.io/docs/manual/patterns/distributed-locks/). While trying to connect to a remote redis cluster I'm facing following error:

Caused by: java.security.cert.CertificateException: No subject alternative names matching IP address 12.23.23.23 found

I added certificate to local keychain but still getting same error.

I tried creating local redis cluster, and was able to verify it standalone. But when I use local cluster to connect via Redisson I'm getting:

org.springframework.data.redis.ClusterStateFailureException: Could not retrieve cluster information. CLUSTER NODES returned with error.

Feeling out of options atm, Need help to get this redisson client running on local.

0

There are 0 best solutions below