Skip to content

Instantly share code, notes, and snippets.

@Abdulsametileri
Created July 5, 2023 20:15
Show Gist options
  • Save Abdulsametileri/1cdb2896d5cb0471de57a705de3ae616 to your computer and use it in GitHub Desktop.
Save Abdulsametileri/1cdb2896d5cb0471de57a705de3ae616 to your computer and use it in GitHub Desktop.
kafka-konsumer/with-retry-manager.go
func main() {
consumerCfg := &kafka.ConsumerConfig{
Reader: kafka.ReaderConfig{
Brokers: []string{"localhost:29092"},
Topic: "standart-topic",
GroupID: "standart-cg",
},
RetryEnabled: true,
RetryConfiguration: kafka.RetryConfiguration{
Topic: "retry-topic",
StartTimeCron: "*/1 * * * *",
WorkDuration: 50 * time.Second,
MaxRetry: 3,
},
ConsumeFn: consumeFn,
}
consumer, _ := kafka.NewConsumer(consumerCfg)
defer consumer.Stop()
consumer.Consume()
}
func consumeFn(message kafka.Message) error {
fmt.Printf("Message From %s with value %s", message.Topic, string(message.Value))
return nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment