Java resilience
Skill ducpm2303/claude-java-plugins/plugins/java-spring/skills/java-resilience
Use when the user asks to add resilience patterns, handle service failures, implement circuit breaker, retry, rate limiter, bulkhead, or timeout in a Spring Boot project using Resilience4J.From its SKILL.md
npx -y skills add ducpm2303/claude-java-plugins --skill java-resilienceAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 17 stars17 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.3 KB, ~1.2k tokens by cl100k_base, as published. Nobody here has run it
Resilience4J Skill
Detect the existing setup, then apply the correct pattern.
Step 1 — Detect setup
Check pom.xml or build.gradle:
resilience4j-spring-boot3→ Spring Boot 3.x (useio.github.resilience4j:resilience4j-spring-boot3)resilience4j-spring-boot2→ Spring Boot 2.xspring-cloud-starter-circuitbreaker-resilience4j→ Spring Cloud Circuit Breaker abstraction- None present → offer to add (recommend
resilience4j-spring-boot3for Boot 3.x)
Check Java version: Java 17+ enables records for fallback DTOs; Java 8+ supported throughout.
Mode: review
User asks to review existing Resilience4J config. Check for:
- Circuit breaker thresholds are tuned —
slidingWindowSize,failureRateThreshold,waitDurationInOpenStateset explicitly (not defaults) -
slowCallDurationThresholdandslowCallRateThresholdconfigured — slow calls should also trip the breaker - Fallback methods match the same signature as the guarded method (same return type +
Throwableparam) -
@CircuitBreakerand@Retrynot stacked withoutfallbackMethodon the outer annotation — will swallow exceptions silently - Retry has
ignoreExceptionsfor business errors (e.g.IllegalArgumentException,EntityNotFoundException) — don't retry 4xx errors -
RateLimiteruseslimitForPeriodappropriate for downstream SLA — not an arbitrary number - Bulkhead
maxConcurrentCallssized against thread pool or reactive scheduler - Actuator endpoints exposed:
management.endpoints.web.exposure.include=health,circuitbreakers,retries,ratelimiters - Circuit breaker state changes logged via
CircuitBreakerEventlistener — not silent - No
@Retryon@Transactionalmethods — retries after a rolled-back transaction reopen a new transaction
Mode: circuit-breaker
User asks to add a circuit breaker to protect a downstream call.
- Add dependency (see
references/patterns.md→ Setup) - Configure in
application.yml— setsliding-window-size,failure-rate-threshold,wait-duration-in-open-state - Annotate the method with
@CircuitBreaker(name = "serviceName", fallbackMethod = "fallback") - Write the fallback method — same return type, extra
Throwableparameter - Expose circuit breaker health:
management.health.circuitbreakers.enabled=true - Add event listener to log state transitions (CLOSED→OPEN→HALF_OPEN)
Version note:
- Spring Boot 3.x →
resilience4j-spring-boot3 - Spring Boot 2.x →
resilience4j-spring-boot2
Mode: retry
User asks to add automatic retry for flaky remote calls.
- Configure retry in
application.yml—max-attempts,wait-duration,exponential-backoff-multiplier - Set
ignore-exceptionsfor non-retryable errors (validation errors, 4xx responses) - Set
retry-exceptionsexplicitly (e.g.IOException,TimeoutException) - Annotate with
@Retry(name = "serviceName", fallbackMethod = "fallback") - For HTTP clients: check response status before retrying — use
retryOnResultPredicateto retry on 5xx, not 4xx - Warn if stacking with
@CircuitBreaker— retry fires first, circuit breaker wraps it; setretry.max-attemptslower than circuit breakersliding-window-size
Mode: rate-limiter
User asks to limit how often a method can be called (outgoing rate limiting or incoming API protection).
- Configure
limit-for-period(requests per window),limit-refresh-period,timeout-duration - Annotate with
@RateLimiter(name = "serviceName", fallbackMethod = "fallback") - For incoming API protection: place on controller method or use a filter
- For outgoing: place on the service/client method calling the downstream
Mode: bulkhead
User asks to limit concurrent calls to isolate failures (prevent thread starvation).
Two types — choose based on context:
- Semaphore bulkhead (default): limits concurrent calls via a counter — lightweight, same thread pool
- ThreadPool bulkhead: executes in a dedicated pool — true isolation, for blocking I/O
Configure max-concurrent-calls and max-wait-duration (semaphore) or pool size (thread pool).
Annotate with @Bulkhead(name = "serviceName", type = Bulkhead.Type.SEMAPHORE).
Mode: timeout
User asks to add a timeout to a method.
- Use
@TimeLimiterfor reactive/async methods (returnsCompletableFutureorFlux/Mono) - For blocking methods: use
@CircuitBreakerwithslowCallDurationThresholdinstead - Configure
timeout-durationinapplication.yml @TimeLimiterrequires the method to returnCompletableFuture<T>— wrap synchronous calls if needed
Output format
For review mode: list findings as [CRITICAL] / [HIGH] / [MEDIUM] / [LOW] with file:line references.
For implementation modes: show exact Maven/Gradle snippet, full application.yml config block, and complete annotated Java example. State minimum Spring Boot version where relevant.
What ships with it: 1 file
7.8 KB alongside SKILL.md
references/
- patterns.md7.8 KB