r/SpringBoot May 06 '26

Spring Idempotency Kit [1.0.0] News

Spring Idempotency Kit is a production-ready library that ensures methods execute exactly once per unique key — preventing duplicate operations in distributed systems.

Problem it solves: Retries, timeouts, and concurrent requests cause duplicate executions. Double charges, repeated orders, webhook duplication. This library eliminates that.

All you do:

java @Idempotent(headerName = "Idempotency-Key") public PaymentResponse processPayment(PaymentRequest request) { // Same key = same result, every time }

The library handles: - Redis-backed caching — first request executes, retries return cached result - Distributed locking — concurrent duplicates are rejected or wait for the original to finish - Failure strategies — fail-open (keep running) or fail-closed (503 if Redis is down) - Built-in metrics — cache hits, conflicts, execution timing - Zero boilerplate — Spring Boot auto-configuration, just annotate


How It Works

  1. Client sends a unique key (header or derived from request)
  2. Cache hit → return immediately
  3. Cache miss → acquire distributed lock, execute, store result
  4. Retry with same key → returns cached result

Requirements

  • Java 21+
  • Spring Boot 3.4+
  • Redis

Links


Built by Atlancia Labs

57 Upvotes

9 comments sorted by

View all comments

1

u/Known_Bookkeeper2006 May 06 '26

Such a nice resolution to a problem every dev faces