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".
In this repository14 other files it gives its agents.
- ai-tell-cleanupSkill
- branch-guardSkill
- frontend-perf-impact-scanSkill
- jvm-memory-leak-reviewSkill
- kotlin-coroutine-reviewSkill
- nestjs-provider-reviewSkill
- nextjs-app-router-reviewSkill
- parallel-devSkill
- parallel-dispatchSkill
- parallel-prSkill
- pr-impact-scanSkill
- react-hooks-reviewSkill
- review-loopSkill
- reviewSkill
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
- Very specific: line 55
If @RetryableTopic and DefaultErrorHandler are both present, they interact — retry-topic takes precedence but the fallback path still runs.
- Very specific: line 67
If the listener launches child jobs (launch { ...
- Distinctive: line 72
Do the message payload + business logic assume at-least-once delivery?
- Distinctive: line 101
Not a full Kafka consumer-group / rebalance audit — that's a broader ops review.
- Very specific: line 102
Not a performance tuner. max.poll.records, fetch.min.bytes etc.
- Distinctive: line 103
Does not fix the code. The user reviews the findings and decides.
≈ “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.
Files
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.gradlevisible so the Spring Kafka + Spring Boot version can be resolved.
Phase 1 — Version fingerprint
Before reviewing, resolve:
- Spring Kafka version (
org.springframework.kafka:spring-kafkain dependencies) - Spring Boot version (BOM)
- Kotlin version if the listener is
suspend
Version matters because several classes of bug are version-specific:
| Pattern | Broken in | Fixed in |
Suspend @KafkaListener unsupported | ≤ 3.2.x | 3.3+ |
RecordInRetryException re-queued into failedRecords causing infinite re-delivery | 4.0.0–4.0.1 | 4.0.2 (fix in GH-4465 / PR #4469) |
| Silent record loss when two records on the same partition fail async | 4.0.0–4.0.x | GH-4504 / PR #4505 |
| Async retry head-of-line amplification unbounded | pre PR #4512 | PR #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(usuallyDefaultErrorHandler) wired? If not, the container falls back to a logging handler that eats poison messages. - Is the backoff bounded (
FixedBackOff,ExponentialBackOffwithmaxRetriesset)? 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
@RetryableTopicin use? If yes:blockingRetryableclasses list is notThrowable.class(which would double-retry everything).attemptsandbackoffare set explicitly.- The DLT strategy is
FAIL_ON_ERRORunless you want silent drop.
- If
@RetryableTopicandDefaultErrorHandlerare both present, they interact — retry-topic takes precedence but the fallback path still runs. Verify the developer intended both.
Ack mode
AckMode.MANUALrequires the listener to callacknowledgment.acknowledge()on every code path. Missing calls = infinite re-delivery.AckMode.RECORDis safe but expensive. Confirm it wasn't picked accidentally whenBATCHwas intended.AckMode.MANUAL_IMMEDIATE+ async processing = high risk of ack-before-commit races.
Suspend / coroutine specifics (Kotlin only)
suspend fun@KafkaListenerrequires 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 unlesscoroutineScope { ... }wraps them.MessageListenerContaineracks on parent return → silent race. CoroutineExceptionHandlermust 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-tracingon 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.bytesetc. are out of scope. - Does not fix the code. The user reviews the findings and decides.
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
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.

