SpringSpring Kafka Configuration
How do you configure the consumer to start from the beginning for a new application deployment?
Reference answer
For a new consumer group set spring.kafka.consumer.auto-offset-reset=earliest. auto.offset.reset (default latest) says what to do when there is no initial offset in Kafka or the current offset no longer exists on the server; earliest resets to the earliest offset available, which is the start of the log and not necessarily offset 0 if old segments were deleted. For later deployments with the same group-id, committed offsets that are still valid are used and auto-offset-reset has no effect, so earliest on a running group with committed offsets does nothing. To re-read all messages, use a new group id, delete the group (kafka-consumer-groups.sh --delete --group my-group; this works only if the group has no active members), or reset its offsets with kafka-consumer-groups.sh --reset-offsets --to-earliest --execute after making sure the consumer instances are inactive. Within the application you can also seek, for example with ConsumerSeekAware.
Expected key concepts: auto-offset-reset, earliest, latest, new consumer group, committed offsets, group-id, reset-offsets, to-earliest, no active members
How did that feel?
Your own verdict, not the score. It shows up next to this question in the list, so you can come back to the shaky ones.