agentleFS
BK202503BK202503/open-claude-all/skills/spring-kafka-listener-review/SKILL.md

spring-kafka-listener-review

Skill7 starsChanged 4 months agoMITView on GitHub

Review a Spring Kafka listener (Java or Kotlin) for common pitfalls before you PR — unbounded async retry, silent record loss on same-partition failures, misconfigured DefaultErrorHandler + RetryTopicConfiguration, missing DLT wiring, suspend @KafkaListener support gaps by version, ack strategy correctness, and consumer-side idempotency assumptions. Triggers include "review my Kafka listener", "check this @KafkaListener", "why does my listener retry forever", "suspend listener retry not working".

The file

We split this skill into the rules it gives an agent

6 rules. About 0 are common, 3 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    If @RetryableTopic and DefaultErrorHandler are both present, they interact — retry-topic takes precedence but the fallback path still runs.

    line 55
  2. Very specific:

    If the listener launches child jobs (launch { ...

    line 67
  3. Distinctive:

    Do the message payload + business logic assume at-least-once delivery?

    line 72
  4. Distinctive:

    Not a full Kafka consumer-group / rebalance audit — that's a broader ops review.

    line 101
  5. Very specific:

    Not a performance tuner. max.poll.records, fetch.min.bytes etc.

    line 102
  6. Distinctive:

    Does not fix the code. The user reviews the findings and decides.

    line 103

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

spring-kafka-listener-review

Spring Kafka's listener + error-handler surface has several known-bad interaction patterns that are silent until production. This skill runs a structured review against a specific listener class or module.

Prerequisites

  • Target listener code is visible in the repo (path or class name).
  • pom.xml / build.gradle visible so the Spring Kafka + Spring Boot version can be resolved.

Phase 1 — Version fingerprint

Before reviewing, resolve:

  • Spring Kafka version (org.springframework.kafka:spring-kafka in dependencies)
  • Spring Boot version (BOM)
  • Kotlin version if the listener is suspend

Version matters because several classes of bug are version-specific:

PatternBroken inFixed in
Suspend @KafkaListener unsupported≤ 3.2.x3.3+
RecordInRetryException re-queued into failedRecords causing infinite re-delivery4.0.0–4.0.14.0.2 (fix in GH-4465 / PR #4469)
Silent record loss when two records on the same partition fail async4.0.0–4.0.xGH-4504 / PR #4505
Async retry head-of-line amplification unboundedpre PR #4512PR #4512

Flag matches upfront so the user knows some of the "bugs" are actually already-known-and-fixed by an upgrade.

Phase 2 — Structural review

Walk the listener and check each item:

Error handling

  • Is a CommonErrorHandler (usually DefaultErrorHandler) wired? If not, the container falls back to a logging handler that eats poison messages.
  • Is the backoff bounded (FixedBackOff, ExponentialBackOff with maxRetries set)? An unbounded backoff blocks the consumer thread forever on a poison message.
  • Is there a recoverer (DeadLetterPublishingRecoverer) after retries exhaust? Without one, the exhausted record is dropped.
  • Does the recoverer publish to a DLT with a naming scheme (<topic>.DLT) the ops team actually monitors?

Retry topic vs blocking retry

  • Is @RetryableTopic in use? If yes:
    • blockingRetryable classes list is not Throwable.class (which would double-retry everything).
    • attempts and backoff are set explicitly.
    • The DLT strategy is FAIL_ON_ERROR unless you want silent drop.
  • If @RetryableTopic and DefaultErrorHandler are both present, they interact — retry-topic takes precedence but the fallback path still runs. Verify the developer intended both.

Ack mode

  • AckMode.MANUAL requires the listener to call acknowledgment.acknowledge() on every code path. Missing calls = infinite re-delivery.
  • AckMode.RECORD is safe but expensive. Confirm it wasn't picked accidentally when BATCH was intended.
  • AckMode.MANUAL_IMMEDIATE + async processing = high risk of ack-before-commit races.

Suspend / coroutine specifics (Kotlin only)

  • suspend fun @KafkaListener requires Spring Kafka 3.3+.
  • Inside a suspend listener, do NOT call runBlocking { ... } — you already have a coroutine scope.
  • If the listener launches child jobs (launch { ... }), the parent will return before children complete unless coroutineScope { ... } wraps them. MessageListenerContainer acks on parent return → silent race.
  • CoroutineExceptionHandler must be installed on the scope, or async failures are swallowed.

Idempotency

  • Do the message payload + business logic assume at-least-once delivery? If the DB write isn't idempotent (missing unique key, no upsert), replays cause duplicates.
  • Consumer group rebalance triggers re-delivery of un-acked records. Verify.

Observability

  • Is micrometer-tracing on the classpath and are listener spans emitted? Without them, you can't correlate a poison-message stall with the offending offset.
  • Is the DLT topic instrumented for alerting?

Phase 3 — Emit findings

For each hit, emit:

[<severity>] <topic>: <one-line summary>
  Where: <file>:<line>
  Why it matters: <impact in 1 sentence>
  Fix: <concrete code change or config setting>
  Reference: <upstream Spring Kafka issue / commit if applicable>

Severity ladder:

  • must-fix — data loss, silent drop, infinite loop
  • should-fix — production ops pain (no DLT, no monitoring)
  • consider — style / idempotency assumption / performance

Sort must-fix first. If there are zero findings, say so plainly — do not invent.

Non-goals

  • Not a full Kafka consumer-group / rebalance audit — that's a broader ops review.
  • Not a performance tuner. max.poll.records, fetch.min.bytes etc. are out of scope.
  • Does not fix the code. The user reviews the findings and decides.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.