Distributed concurrency toolkit for Java + PostgreSQL.
Three lock strategies - advisory, session, and lease - all backed by PostgreSQL. Zero dependencies beyond java.sql.
<dependency>
<groupId>com.pivovarit</groupId>
<artifactId>fencepost</artifactId>
</dependency>
Lock strategies
Pick the strategy that fits your workload. All three implement the same API.
PostgreSQL advisory locks. No table setup. Simplest option - just point at a DataSource and go.
SELECT ... FOR UPDATE with monotonic fencing tokens. Rejects stale writes from superseded holders.
Timestamp TTL with optional heartbeat. Releases the connection immediately - best for long-running work.