Scrivio Interview library
DebuggingIntermediate7 min read · updated 12 November 2026

A new @KafkaListener(topics = "invoices") in a service never receives messages, while another listener in the same application works. No errors appear at startup. List the configuration causes you would check, in order.

Try it yourself

Consumer group: who reads which partition

Change the number of partitions and consumers, and see who owns what, who is idle, and where ordering holds.

Read this example as text

Who reads which partition

  1. 3 partitions, 2 consumers. C0 reads P0, P1; C1 reads P2.
  2. 4 partitions, 2 consumers. C0 reads P0, P1; C1 reads P2, P3.
  3. 3 partitions, 3 consumers. C0 reads P0; C1 reads P1; C2 reads P2.
  4. 6 partitions, 4 consumers. C0 reads P0, P1; C1 reads P2, P3; C2 reads P4; C3 reads P5.
  5. 2 partitions, 4 consumers. C0 reads P0; C1 reads P1; C2 is idle; C3 is idle.

A partition has exactly one reader in the group. A consumer beyond the number of partitions is idle.

Six records with 3 partitions and 2 consumers

  1. Record A1. Key A goes to P0, read by C0.
  2. Record B1. Key B goes to P1, read by C0.
  3. Record A2. Key A goes to P0, read by C0.
  4. Record C1. Key C goes to P2, read by C1.
  5. Record B2. Key B goes to P1, read by C0.
  6. Record A3. Key A goes to P0, read by C0.

A1, A2 and A3 sit in one partition and are read in that order. Nothing orders a record in one partition against a record in another.

What this example leaves out
  • One topic, and Kafka's range assignor, the first in the default list. Other assignors spread partitions differently.
  • A, B and C stand for key hashes 0, 1 and 2. The real client hashes the key bytes; the rule shown, same key to the same partition, is the same.
  • A rebalance is shown as instant. In a real group, consumers stop briefly while partitions move.

When a @KafkaListener starts without errors but never receives anything, the cause is almost always configuration rather than code. We check, in order, the consumer group (its id, who else owns the partitions and where its committed offsets are), the starting position set by auto.offset.reset, whether the container was started at all (autoStartup and the containerFactory it uses), whether the class is a Spring bean, and finally the topic name and ACLs, using the partition assignment log and kafka-consumer-groups to confirm each step.

Why this question is asked

A silent listener is one of the most common Kafka problems in Spring applications, and it is frustrating because nothing fails. The application starts, the other listener works, and the new one simply does nothing. Interviewers like this question because a good answer is a method, not a guess: we move from the cheapest and most likely causes to the rarer ones, and we use evidence at each step instead of changing settings at random. In this answer, we will recap what a listener needs in order to receive a record, go through the causes in the order we would check them, and see which log lines and commands prove or rule out each one.

1A Quick Recap: What a Listener Needs to Receive a Record

A @KafkaListener method does not read from Kafka by itself. At startup, Spring finds the annotation on a bean, creates an endpoint for it, and a listener container factory turns that endpoint into a listener container: a small engine that owns a KafkaConsumer, polls it in a loop on its own thread and calls our method for each record.

For a record to arrive, a whole chain has to work. The class must be a Spring bean so the annotation is found. The container must be started. Its consumer must join a consumer group, a set of consumers that share a topic under one group.id, and the group coordinator on the broker must assign it at least one partition of the topic. Finally, the consumer must start reading at a position where records actually exist. A break anywhere in this chain gives the same symptom: silence.

Step throughThe chain from annotation to record
  1. Class is a Spring beanotherwise the annotation is never seen
  2. Endpoint registered with an idvisible in KafkaListenerEndpointRegistry
  3. Container started?
    YesConsumer joins the groupNoautoStartup false or factory issue
  4. Partitions assigned?
    YesConsumer fetches from a positionNoanother member or wrong topic
  5. Records after that position?
    YesListener method is calledNooffset reset latest or offsets past the data

5 steps in order. Play them, or step through them one at a time.

2Check 1: The Group Id and Its Committed Offsets

The group id decides two things: which consumers share partitions with ours, and where our reading position is stored. A completely missing group id is not the problem here, because the container refuses to start without one when it subscribes to a topic, and we would see an error. The silent cases come from a wrong or reused group id.

A common trap is the id attribute. In Spring Kafka, @KafkaListener(id = "orders") also uses that id as the group id unless we set groupId, because idIsGroup is true by default. If the new invoices listener was copied from the working one and kept the same id or groupId, both listeners now belong to one group. Kafka assigns each partition to only one member of a group, and if the two listeners subscribe to different topics, the result can be confusing. A different danger is reusing the group id of another application that already reads invoices: that application owns the partitions, or the group has offsets committed far past the records we expect, so our consumer starts at the end.

Java
// Copied from the working listener: same id, so same group by default
@KafkaListener(id = "payments", topics = "invoices") // group.id = payments
public void onInvoice(Invoice invoice) { ... }
// Fixed: its own id and an explicit, unique group
@KafkaListener(id = "invoiceListener", groupId = "billing-invoices", topics = "invoices")
public void onInvoice(Invoice invoice) { ... }

We confirm the group with the command line. kafka-consumer-groups --bootstrap-server broker:9092 --describe --group billing-invoices shows each partition, the member that owns it, the committed offset, the log end offset and the lag. If the owner is a host from another service, or the committed offset equals the end offset while we expected old records, we have found the cause.

3Check 2: Where a New Group Starts Reading

When a group has no committed offset for a partition, the consumer falls back to auto.offset.reset. Its default is latest, which means a new group starts at the end of the partition and only sees records produced after it joined. If we tested by producing a few invoices and then starting the service, those invoices are before the starting point and are never read. Nothing is wrong with the listener; it is waiting for the next record.

If we want a new group to read existing records, we set spring.kafka.consumer.auto-offset-reset=earliest, or per listener properties = "auto.offset.reset=earliest". Remember that this only applies when there is no committed offset. Once the group has committed, changing the setting does nothing, and we would reset the offsets with kafka-consumer-groups --reset-offsets instead.

4Check 3: Was the Container Started, and With Which Factory?

A listener container may simply not be running. autoStartup = "false" on the annotation, or setAutoStartup(false) on the factory, creates the container but never starts it, which is sometimes done on purpose so another component starts it later and then forgets. The second cause in this group is the containerFactory attribute. If the invoices listener names a different factory, for example one built for another cluster, it may use other bootstrap servers, another group id property or different deserializers. A container connected to the wrong cluster will happily wait on a topic that has no traffic there.

Java
@Autowired KafkaListenerEndpointRegistry registry;
MessageListenerContainer c = registry.getListenerContainer("invoiceListener");
System.out.println(c); // null: no endpoint was registered at all
System.out.println(c.isRunning()); // false: created but never started
System.out.println(c.getAssignedPartitions()); // []: running, but owns no partition

These three lines separate the cases cleanly. A null container points to the bean problem in the next check, a container that is not running points to autoStartup, and a running container with no partitions points back to the group or the topic.

5Check 4: Is the Class a Spring Bean at All?

Spring only processes @KafkaListener on beans. If the class sits in a package outside component scanning, if it is guarded by @Profile("prod") while we run with another profile, or if a @ConditionalOnProperty switches it off, no bean is created and therefore no endpoint and no container. There is no error, because from Spring's point of view there is nothing to report. The registry check above returns null for the listener id, and the startup log has no line for that container. Looking at /actuator/beans, or simply adding a log line to the constructor, settles it in seconds.

6Check 5: Topic Name, Assignment Logs and ACLs

When the container runs but owns nothing, we read the assignment logs. Spring Kafka logs a line such as "partitions assigned: [invoices-0, invoices-1]" at INFO for each container, and the Kafka client logs the newly assigned partitions as well. If that line is missing, or the list is empty, the consumer is not getting partitions.

Then we verify the topic name exactly. A typo such as "invoice" instead of "invoices" is silent when the broker has auto topic creation disabled, because subscribing to a topic that does not exist does not fail. Finally, on a secured cluster the principal needs Read on the topic and Read on the group. A missing topic ACL usually shows a TopicAuthorizationException in the log, but a missing group ACL can show up only as repeated join failures, so we check the ACLs with kafka-acls --list.

Evidence for each cause
CauseWhat proves it
Group reused or shareddescribe --group shows another owner or no lag
auto.offset.reset latestcommitted offset equals end offset, old records unread
autoStartup falsecontainer exists, isRunning() is false
Wrong containerFactorybootstrap servers or deserializers differ in the log
Not a beanregistry returns null for the listener id
Topic name or ACLsno partitions assigned line, or authorization errors
Each check has a piece of evidence, so we never change two settings at once.

7Follow-up questions

How would you make a missing partition assignment visible in health checks?

I would add a custom Actuator HealthIndicator that walks KafkaListenerEndpointRegistry.getListenerContainers() and reports DOWN, or a separate status such as OUT_OF_SERVICE, when a container that should be running is not running or has had an empty getAssignedPartitions() for longer than a grace period, for example two minutes after startup. The grace period matters because during a rebalance a container briefly has no partitions. Alongside the health check I would export a gauge with the number of assigned partitions per listener and alert on consumer lag, so a group that stops reading is noticed even if the health check passes.

8Conclusion

In this answer, we treated a silent listener as a broken chain and checked the links in order: the group id and its committed offsets, the auto.offset.reset default of latest for a new group, whether the container was started and built by the right factory, whether the class is a bean at all, and finally the topic name and ACLs. For each one we had evidence: the registry, the partitions assigned log line and kafka-consumer-groups --describe. A health check that reports containers without partitions turns the next silent listener into a visible alert.

What to say in the interviewAbout 80 seconds aloud

Open with

Because nothing fails at startup, I would assume a configuration problem and go through the chain from annotation to record. First the group id: in Spring Kafka the listener id becomes the group id unless groupId is set, so a copied listener can share a group, and a reused group id can mean another application owns the partitions or the committed offsets are already at the end.

Then, if they want more

I check that with kafka-consumer-groups describe. Second, the starting position: a new group with the default auto offset reset of latest only sees records produced after it joined, so test messages sent earlier are never read.

Third, whether the container runs at all: autoStartup false on the annotation or the factory, or a containerFactory attribute pointing to a factory with other bootstrap servers or deserializers. I look the listener up in KafkaListenerEndpointRegistry and check isRunning and getAssignedPartitions.

If the registry has nothing, the class probably is not a bean, because it is outside component scanning or switched off by a profile or condition. Last, the topic name and ACLs, using the partitions assigned line in the INFO logs.

To catch it next time, I would add a health indicator that reports containers that have no assigned partitions after a grace period.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "A new @KafkaListener(topics = "invoices") in a service never receives messages, while...": https://scrivio-interview-library.netlify.app/spring-boot/kafka/f284fb6990/