distributed-locking-rfc-44_skill

This skill helps you implement RFC-44 compliant distributed locking using PostgreSQL or Redis to coordinate jobs across instances.
  • JavaScript

35

GitHub Stars

1

Bundled Files

2 months ago

Catalog Refreshed

4 months ago

First Indexed

Readme & install

Copy the install command, review bundled files from the catalogue, and read any extended description pulled from the listing source.

Installation

Preview and clipboard use veilstrat where the catalogue uses aiagentskills.

npx veilstrat add skill bitsoex/bitso-java --skill distributed-locking-rfc-44

  • SKILL.md4.6 KB

Overview

This skill documents RFC-44 compliant distributed locking patterns for Java services, covering PostgreSQL advisory locks and Redis-based locking. It provides quick-start instructions, implementation choices, migration workflows, and common usage patterns to implement or migrate distributed locks safely. Use it to standardize locking across services and to guide migrations from legacy mechanisms.

How this skill works

The skill explains two supported implementations: PostgreSQL advisory locks (default) and Redis-based locks (allowed when PostgreSQL is unavailable or justified). It shows how to wire a DistributedLockManager bean, obtain locks with tryLock, and use try-with-resources or functional patterns to ensure deterministic release. It also includes migration steps, integration details, and troubleshooting guidance.

When to use it

  • Implementing distributed locking for scheduled jobs or singleton tasks
  • Migrating from legacy or in-repo lock implementations to RFC-44
  • Choosing between PostgreSQL advisory locks and Redis-based locking
  • Replacing Fabric8 leader election or other leader patterns
  • Making locks RFC-44 compliant across a service fleet

Best practices

  • Prefer PostgreSQL advisory locks when a PostgreSQL instance is available and latency is acceptable
  • Use try-with-resources to guarantee lock release even on exceptions
  • Only use Redis locking when PostgreSQL is unavailable or when its semantics are explicitly needed
  • Instrument lock acquisition and release for observability and alerting
  • Follow the provided migration workflow for zero-downtime transitions

Example use cases

  • Preventing concurrent execution of a scheduled job across multiple instances using a JooqPostgresSessionDistributedLockManager
  • Migrating an existing Fabric8 leader-election job to RFC-44 compliant advisory locks
  • Using Redis locks for stateless services that do not have database access
  • Adopting try-with-resources pattern to simplify lock lifecycle management in background tasks
  • Applying the migration workflow to move from an incubated in-repo library to the shared distributed-locking API

FAQ

No. Redis-based locking is explicitly supported when PostgreSQL is not available or when Redis is the justified choice.

How do I ensure a lock is always released?

Use try-with-resources or equivalent patterns so the lock is closed in a finally-like block; this ensures release even if the task throws.

Built by
VeilStrat
AI signals for GTM teams
© 2026 VeilStrat. All rights reserved.All systems operational