You can reset a consumer offset to change the current consumption position of a consumer. You can reset the consumer offset to skip the accumulated or undesired messages instead of consuming them, or to consume messages after a time point regardless of whether the messages before this time point have been consumed.
Prerequisites
Notice After a consumer is stopped, the broker waits for a period of time, which is specified
in
ConsumerConfig.SESSION_TIMEOUT_MS_CONFIG
(10,000 ms by default), and then determines that the consumer has been stopped.
Background information
Message Queue for Apache Kafka supports the following modes of consumer offset resetting:
- Clear messages: If a consumer does not want to consume accumulated messages on the
broker any more, you can choose to clear messages for the consumer. This way, the
consumption offset for the consumer is set to the latest position.
Notice Accumulated messages are not deleted. Only the consumer offset is changed.
- Start consumption at the specified time point: You can reset the offset of a consumer group to a time point "t" in the past or future, that is, a time point when a message is stored. Then, the consumer group subscribes to messages stored after "t".