Class ConsulLockProvider

java.lang.Object
net.javacrumbs.shedlock.provider.consul.ConsulLockProvider
All Implemented Interfaces:
AutoCloseable, LockProvider

public class ConsulLockProvider
extends Object
implements LockProvider, AutoCloseable

This lock provider registers a new session for lock and on unlock this session is removed together with all associated locks.

The main point you need to be aware about is that consul holds session for up to twice TTL. That means, even if the session TTL is set to 10 seconds, consul will hold still this session for 20 seconds. This is an expected behaviour and it's impossible to change it. This is the reason consul recommends to set the lowest possible TTL and constantly extend it. With this lock it means that even if your lockAtMostFor is less that 20 seconds, the timeout will be higher than 10 seconds and most likely will be 20.

The lock is acquired for the time specified in @SchedulerLock.lockAtMostFor. Please note that this lock provider doesn't make any correction to the aforementioned TTL behaviour so most likely your locked session will live for longer than specified in lockAtMostFor. In this lock provider there is no session renewal done in the background.

Author:
Artur Kalimullin
  • Constructor Details

    • ConsulLockProvider

      public ConsulLockProvider​(com.ecwid.consul.v1.ConsulClient consulClient)
    • ConsulLockProvider

      public ConsulLockProvider​(com.ecwid.consul.v1.ConsulClient consulClient, Duration minSessionTtl)
    • ConsulLockProvider

      public ConsulLockProvider​(com.ecwid.consul.v1.ConsulClient consulClient, Duration minSessionTtl, String consulLockPostfix, Duration gracefulShutdownInterval)
    • ConsulLockProvider

      public ConsulLockProvider​(ConsulLockProvider.Configuration configuration)
  • Method Details