Search code examples
apache-kafkakafka-consumer-apispring-kafka

@KafkaListener and one single Consumer


I have this method

@KafkaListener(topics={"one", "two", "three"})
public void listen(String message) { ...}

How can listener container instantiate only one single Consumer independently from topics and partition.

For example, if I have these partition:

one-0
one-1
two-0
three-0
three-1

There is a way for assigning all these partition to the same single Consumer? Is ConcurrentKafkaListenerContainerFactory's concurrency value to 1 enough for this purpose?


Solution

  • Thats's exactly what you'll get by default (with concurrency=1, default).

    Watch for the INFO log Partitions assigned ....