Class Neo4jLockProvider
java.lang.Object
net.javacrumbs.shedlock.support.StorageBasedLockProvider
net.javacrumbs.shedlock.provider.neo4j.Neo4jLockProvider
- All Implemented Interfaces:
ExtensibleLockProvider,LockProvider
Lock provided by Neo4j Graph API. It uses a collection that stores each lock as a node.
- Attempts to insert a new lock node. Since lock name has a unique constraint, it fails if the record already exists. As an optimization, we keep in-memory track of created lock nodes.
- If the insert succeeds (1 node inserted) we have the lock.
- If the insert failed due to duplicate key or we have skipped the insertion, we will try to update lock node using MATCH (lock:collectionName) WHERE name = $lockName AND lock_until <= $now SET lock_until = $lockUntil, locked_at = $now with some additional explicit node locking
- If the update succeeded (>1 property updated), we have the lock. If the update failed (<=1 properties updated) somebody else holds the lock or grabbed the lock in a data race caused by Neo4j's read-committed isolation level.
- When unlocking, lock_until is set to now.
-
Constructor Summary
ConstructorsConstructorDescriptionNeo4jLockProvider(org.neo4j.driver.Driver driver) Neo4jLockProvider(org.neo4j.driver.Driver graphDatabaseService, String collectionName, String databaseName) -
Method Summary
Methods inherited from class net.javacrumbs.shedlock.support.StorageBasedLockProvider
clearCache, doLock, lock
-
Constructor Details
-
Neo4jLockProvider
public Neo4jLockProvider(org.neo4j.driver.Driver driver) -
Neo4jLockProvider
-