jwrookie opened a new issue #746:
URL: https://github.com/apache/rocketmq-client-go/issues/746


   测试场景:
   ● 一个生产者,生产5条消息,默认4个队列
   ● 3个消费者
   
   消费者:
   `
   package main
   
   import (
        "context"
        "fmt"
        "os"
        "time"
   
        "github.com/apache/rocketmq-client-go/v2"
        "github.com/apache/rocketmq-client-go/v2/consumer"
        "github.com/apache/rocketmq-client-go/v2/primitive"
   )
   
   func main() {
        c, _ := rocketmq.NewPushConsumer(
                consumer.WithGroupName("testGroup007"),
                
consumer.WithNsResolver(primitive.NewPassthroughResolver([]string{"172.17.0.6:9876"})),
                consumer.WithConsumeMessageBatchMaxSize(1),
        )
        err := c.Subscribe("test007", consumer.MessageSelector{}, func(ctx 
context.Context,
                msgs ...*primitive.MessageExt) (consumer.ConsumeResult, error) {
                fmt.Println(len(msgs))
                for i := range msgs {
                        fmt.Printf("subscribe callback: %v \n", msgs[i])
                }
                fmt.Println("---------------------------------")
                time.Sleep(time.Second * 1)
   
                return consumer.ConsumeRetryLater, nil
        })
        if err != nil {
                fmt.Println(err.Error())
        }
        // Note: start after subscribe
        err = c.Start()
        if err != nil {
                fmt.Println(err.Error())
                os.Exit(-1)
        }
        time.Sleep(time.Hour)
        err = c.Shutdown()
        if err != nil {
                fmt.Printf("shutdown Consumer error: %s", err.Error())
        }
   }
   `
   
   结果:发现重试队列有非常多重复的数据
   
![image](https://user-images.githubusercontent.com/41732283/143801326-e1ac2ba8-048e-4500-b492-1a267d7085a0.png)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to