I am trying to read from latest available offset (no offset commited for consumer group), so I specify in properties
spring.cloud.stream.bindings.process-in-0.group=test-group
spring.cloud.stream.bindings.process-in-0.auto-offset-reset=latest
But in logs ConsumerConfig values are set to earliest.
If I remove group setting, leaving only:
spring.cloud.stream.bindings.process-in-0.auto-offset-reset=latest
It starts reading only new messages for anonymous consumer. How to make this work also for consumer group?
Anonymous consumers (the ones without an explicit group.id
), will always receive records from the latest
only. The consumers with a group.id
by default, receive records from the earliest
. To change this to the latest
, you need to set the start-offset
property on the proper Kafka binding.
spring.cloud.stream.kafka.bindings.process-in-0.consumer.start-offset=latest
.
Relevant sections from the reference docs: https://docs.spring.io/spring-cloud-stream/reference/4.1-SNAPSHOT/kafka/kafka-binder/config-options.html#kafka-consumer-properties
and