Browse Source

Merge pull request #1338 from bailu1901/master

[fix] run multi consumer group instance crash
Vlad Gorodetsky 6 years ago
parent
commit
d6a75f307a
1 changed files with 2 additions and 3 deletions
  1. 2 3
      examples/consumergroup/main.go

+ 2 - 3
examples/consumergroup/main.go

@@ -70,9 +70,7 @@ func main() {
 	/**
 	 * Setup a new Sarama consumer group
 	 */
-	consumer := Consumer{
-		ready: make(chan bool, 0),
-	}
+	consumer := Consumer{}
 
 	ctx := context.Background()
 	client, err := sarama.NewConsumerGroup(strings.Split(brokers, ","), group, config)
@@ -82,6 +80,7 @@ func main() {
 
 	go func() {
 		for {
+			consumer.ready = make(chan bool, 0)
 			err := client.Consume(ctx, strings.Split(topics, ","), &consumer)
 			if err != nil {
 				panic(err)