본문으로 건너뛰기
cccskills
무료GitHub에 공개

idempotency-patterns

Use when making retried HTTP commands or message processing safe against duplicate effects, including database-backed request keys, payload conflicts and concurrent retries. Do not apply caching as a substitute for business idempotency.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

연동 도구PostgreSQL
설치 방법 보기

포함된 파일(4)

  • SKILL.md3.9 KB
  • agents/openai.yaml261 B
  • examples/bad-idempotency.java303 B
  • examples/good-idempotency.sql964 B

SKILL.md(원문)

설치하기 전에 에이전트에게 전달되는 지시 내용을 확인할 수 있습니다.

Idempotency Patterns

Spring Boot 3 baseline

The examples use Java 17 and Jakarta APIs supported by this Boot version. Keep dependencies managed by the project's Boot BOM.

Define the contract

Identify the authenticated tenant/principal, operation, idempotency key, canonical request hash, retention window and replayable result. Scope uniqueness by principal/tenant and operation; a raw client key must never allow reading another user's result. Authenticate and authorize before both initial execution and replay. Bound key length and stored response size. Document what same-key/different-payload and still-in-progress requests return.

Database-local effects

For PostgreSQL, the schema and claim example uses a composite primary key and INSERT ON CONFLICT DO NOTHING RETURNING. In a single database transaction: claim the key, apply the business write, store the resulting status/body/selected headers, then commit. Roll back the claim with the business mutation on failure.

If the insert returns no row, load the existing result in a subsequent statement under READ COMMITTED, compare the canonical hash and replay only when it matches. A concurrent insert waits on the uniqueness constraint; bound lock waits and return a documented retryable outcome on timeout. With snapshot isolation, serialization failures require retrying the whole transaction. Do not catch a unique-constraint violation and continue in an already-aborted transaction.

A result row and business write must use the same transaction manager and database. Return the stored result rather than reconstructing it from mutable current entity state. Keep replay headers allowlisted; do not persist cookies, bearer tokens or hop-by-hop headers.

External effects and messages

A database transaction cannot atomically include an HTTP payment or email. Write an outbox record with the business mutation and let a retryable worker perform the external effect using the provider's idempotency support. Reconcile uncertain outcomes before retrying irreversible effects. For messages, record a unique consumer/event pair and apply the projection in one transaction; acknowledge only after commit. Retry failed transactions and route poison messages deliberately.

Define retention from the real client retry window. Deleting a key permits a later repeat to execute again; do not present TTL as an exactly-once guarantee. Protect stored responses as application data and delete them according to the project's retention policy.

Verification

Test simultaneous identical requests, conflicting payloads, tenant separation, rollback after claim, response replay after a lost connection and retries following a worker crash. Use the production database engine for lock and isolation tests, not H2 compatibility mode. The bad example illustrates the check-then-act race.

Gotchas

  • Agent checks existence then inserts - enforce uniqueness in the database.
  • Agent uses a JVM map or Redis TTL as the only business guard - coordinate with the actual write transaction.
  • Agent replays another tenant's result - scope the key and re-authorize.
  • Agent retries an external effect after a timeout blindly - reconcile or use provider idempotency.
  • Agent deletes keys too early - document the retry window and expiry semantics.

Official sources

리뷰

아직 리뷰가 없습니다. 사용해 본 소감을 남겨 주세요.

댓글

로그인 없이 쓸 수 있습니다. 사용 후기, 질문, 작동하지 않은 환경 등을 편하게 남겨 주세요.

아직 댓글이 없습니다. 첫 댓글을 남겨 보세요.

보내면 바로 공개됩니다. 이메일 주소나 전화번호 같은 개인 정보는 쓰지 마세요. URL은 2개까지입니다.

0 / 1,000자

이 양식은 reCAPTCHA로 보호되며 Google 개인정보처리방침 및 서비스 약관이 적용됩니다.

같은 저장소의 스킬

Use when adding Spring AI-specific model observations, token usage, latency, externally configured cost attribution, advisor telemetry, or protected prompt and completion logging. Use production-observability for general service metrics, health, logs, and OTLP setup.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3112026년 10월 17일 업데이트

Use when versioning Spring MVC or WebFlux APIs in Spring Boot 3 / Spring Framework 6. Covers explicit URL, header, and media-type strategies, compatibility rules, and deprecation handling.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3112026년 10월 17일 업데이트

Use when versioning Spring MVC or WebFlux APIs in Spring Boot 4 / Spring Framework 7. Covers built-in mapping versions, request version resolution, defaults, supported versions, and deprecation headers.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3112026년 10월 17일 업데이트

Use when introducing or correcting grouped Spring Boot configuration, typed property binding, validation, profiles or secret injection. Do not rewrite unrelated single-value configuration.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3112026년 10월 17일 업데이트

Use when packaging Spring Boot 4 as an OCI image, JVM container, AOT application, or GraalVM native executable. Covers buildpacks, layers, runtime hints, probes, security, and verification.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3112026년 10월 17일 업데이트

Use when packaging a Spring Boot 3 application as an OCI image or GraalVM native executable. Covers buildpacks, layered images, JVM containers, AOT hints, probes, security, and verification.

한국어 요약은 준비 중입니다. 원문 설명을 표시하고 있습니다.

rrezartprebreza/spring-boot-skills3112026년 10월 17일 업데이트

rrezartprebreza의 스킬 모두 보기

이 스킬의 문제 신고