Skip to content

Find the total number of messages in a topic #2928

Closed Answered by aneeskA
aneeskA asked this question in Q&A
Discussion options

You must be logged in to vote

Not sure if this will help someone, but I ended up using "github.com/confluentinc/confluent-kafka-go/v2/kafka" to solve this.

Here is the code that I used. The time difference is massive in my experience.

package main

import (
	...
	"github.com/confluentinc/confluent-kafka-go/v2/kafka"
)

func main() {

	...

	c, err := kafka.NewConsumer(&kafka.ConfigMap{
		"bootstrap.servers": bootstrapServers,
		"broker.address.family": "v4",
		"group.id":              group,
		"session.timeout.ms":    6000,
		"auto.offset.reset": "earliest",
		"enable.auto.offset.store": false,
	})

	if err != nil {
		fmt.Fprintf(os.Stderr, "Failed to create consumer: %s\n", err)
		os.Exit(1)
	}

	fmt.Printf("Created …

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by aneeskA
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant