VCF Operations Orchestrator
Process locking made easy in VCF Operations Orchestrator, featuring automatic unlock

VCF Operations Orchestrator has a built-in locking semaphore provided by the LockingSystem class. When a lock is created, the workflow is placed into a waiting state, and any additional executions of the workflow will be placed in a queue until the lock is released.
Locking protects data consistency by preventing multiple processes from updating the same resource at once. This matters when concurrent workflows share resources.
The LockingSystem method lock attempts to acquire a lock for a given lockId and owner. It returns true if successful, or false otherwise.
LockAndWait waits indefinitely if it cannot acquire a lock. I use lock instead because it allows a timeout or other corrective handling. Release an acquired lock with unlock.
My LockingService extends LockingSystem with these features:
- Retries failed lock attempts with a configurable delay in seconds. The defaults are 5 attempts and 60 seconds. Configure the wait time independently for each use case.
- Can remove an existing lock automatically after the maximum attempts. This helps when a failed workflow run leaves a stale lock.
You can download my LockingService module as a package here or as native JS here.
Use LockingService
Import LockingService into an action or workflow with the following code:
var locking = new (System.getModule("com.simplygeek.vcf.orchestrator.locking").LockingService());
The code creates a LockingService instance in locking. Use that variable to create and remove locks, or rename it if needed.
Available methods
Use these LockingService methods to create and remove locks:
createLock
locking.createLock(lockOwner, lockId, retryMaxAttempts, retryDelay, autoRemoveLock) → {Boolean}
Parameters:
| Name | Type | Description |
|---|---|---|
| lockOwner | String | The lock owner |
| lockId | String | The unique (per lock) id |
| retryMaxAttempts | Number | OPTIONAL – The maximum number of attempts to retry lock (default 5) |
| retryDelay | Number | The delay between retry attempts (default 60 seconds) |
| autoRemoveLock | Boolean | Automatically remove the lock if one is already present and the max retry attempts have been reached. A new lock is created (default true) |
Returns a boolean.
removeLock
locking.removeLock(lockOwner, lockId)
Parameters:
| Name | Type | Description |
|---|---|---|
| lockOwner | String | The lock owner |
| lockId | String | The unique (per lock) id |
Example using default values
var locking = new (System.getModule("com.simplygeek.vcf.orchestrator.locking").LockingService());
locking.createLock("IPAM", subnetId);
// Update operation
locking.removeLock("IPAM", subnetId);
Example using custom values
var locking = new (System.getModule("com.simplygeek.vcf.orchestrator.locking").LockingService());
var retryMaxAttempts = 20;
var retryDelay = 60;
var autoRemoveLock = false;
locking.createLock("IPAM", subnetId, retryMaxAttempts, retryDelay, autoRemoveLock);
// Update operation
locking.removeLock("IPAM", subnetId);
Thanks for reading, and please let me know if you have any suggestions for improving this service.
Join the discussion
Sign in with GitHub to leave a comment. View discussions on GitHub.

