I have three questions:
- what is the meaning of "oldest offset"? Oldest offset doesn't mean offset 0?
// OffsetOldest stands for the oldest offset available on the broker for a
// partition.
OffsetOldest int64 = -2
Supposing
A. Three brokers running on same machine
B. The consumer group has only one consumer thread
C. The consumer configs OffsetOldest flag.
D. There have been 100 msgs produced and currently the consumer thread have consumed 90 msgs.So if the consumer thread restarted, then which offset will this consumer start to consume from? it is 91 or 0?
In our code below, it seems to reconsume messages everytime the consumer is started. but actually it doest happen all times. Why reconsuming just happens a few times just after restart(not all)?
func (this *consumerGroupHandler) ConsumeClaim(session sarama.ConsumerGroupSession, claim sarama.ConsumerGroupClaim) error { for message := range claim.Messages() { this.handler(message) session.MarkMessage(message, "") } return nil } ctx := context.Background() conf := sarama.NewConfig() conf.Version = sarama.V2_0_0_0 conf.Consumer.Offsets.Initial = sarama.OffsetOldest conf.Consumer.Return.Errors = true consumer, err := sarama.NewConsumerGroup(strings.Split(app.Config().KafkaBrokers, ","), groupId, conf) if err != nil { logger.Error("NewConsumerGroupFromClient(%s) error: %v", groupId, err) return }