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


   代码:
   
   c, err := rocketmq.NewPushConsumer(
                consumer.WithNameServer(primitive.NamesrvAddr{"...."}),
                
//producer.WithNsResolver(primitive.NewPassthroughResolver(endPoint)),
                consumer.WithGroupName("...."),
                consumer.WithCredentials(primitive.Credentials{
                        AccessKey: "....",
                        SecretKey: "...",
                }),
                consumer.WithNamespace("......"),
        )
        if err != nil {
                panic(err)
        }
   
        err = c.Subscribe("spider_product", consumer.MessageSelector{}, 
func(ctx context.Context,
                msgs ...*primitive.MessageExt) (consumer.ConsumeResult, error) {
                for i := range msgs {
                        fmt.Printf("subscribe callback: %v \n", msgs[i])
                }
   
                return consumer.ConsumeSuccess, nil
        })
        if err != nil {
                panic(err)
        }
        // 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())
        }
   
   代码如上
   
相当于只有PushConsumer服务订阅开启后,生产消息才能消费,如果服务没有开启,没有订阅,先去生产消息,在进行订阅,就消费不了,之前的一大推消息都消费不成功
   
   
   
   
   


----------------------------------------------------------------
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.

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


Reply via email to