We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func main() { r := kafka.NewReader(kafka.ReaderConfig{ Brokers: []string{"localhost:9092"}, Topic: "my-topic", Partition: 0, MaxBytes: 10e6, // 10MB }) for { m, err := r.ReadMessage(context.Background()) if err != nil { break } fmt.Printf("message at offset %d: %s = %s\n", m.Offset, string(m.Key), string(m.Value)) r.CommitMessages(context.Background(), m) // commit offset }
if err := r.Close(); err != nil { log.Fatal("failed to close reader:", err) }
}
I submitted the offset, but each time I execute the program, it starts from the beginning, resulting in repeated consumption.
===============First Execution=========== message at offset 0: = one! message at offset 1: = two! message at offset 2: = three!
============== Second Execution ========= message at offset 0: = one! message at offset 1: = two! message at offset 2: = three!
The text was updated successfully, but these errors were encountered:
i think you must use the consumer group to do this.
Sorry, something went wrong.
No branches or pull requests
func main() {
r := kafka.NewReader(kafka.ReaderConfig{
Brokers: []string{"localhost:9092"},
Topic: "my-topic",
Partition: 0,
MaxBytes: 10e6, // 10MB
})
for {
m, err := r.ReadMessage(context.Background())
if err != nil {
break
}
fmt.Printf("message at offset %d: %s = %s\n", m.Offset, string(m.Key), string(m.Value))
r.CommitMessages(context.Background(), m) // commit offset
}
}
I submitted the offset, but each time I execute the program, it starts from the beginning, resulting in repeated consumption.
===============First Execution===========
message at offset 0: = one!
message at offset 1: = two!
message at offset 2: = three!
============== Second Execution =========
message at offset 0: = one!
message at offset 1: = two!
message at offset 2: = three!
The text was updated successfully, but these errors were encountered: