Search code examples
apache-kafkaspring-kafka

When using @KafkaListener can I get a reference to the underlying KafkaConsumer as I want to read the endOffsets


When using @KafkaListener can I get a reference to the underlying KafkaConsumer as I want to read the endOffsets


Solution

  • Just add a Consumer<?, ?> parameter to the listener method.

    The consumer is not thread-safe so you should only invoke it on the listener thread.

    Requires 2.0 or later; the current release is 2.2.3.