yfanswer commented on issue #954:
URL:
https://github.com/apache/rocketmq-client-go/issues/954#issuecomment-1298256159
func (pc *PullConsumer) Poll(ctx context.Context, topic string) error {
logger := logx.WithContext(ctx)
if err := pc.pullConsumer.Subscribe(topic, consumer.MessageSelector{});
err != nil {
return perrors.WithStack(err)
}
if err := pc.Start(); err != nil {
return err
}
for {
cr, err := pc.pullConsumer.Poll(ctx, 5*time.Second)
if err != nil {
logger.Errorf("consumer poll failed, error:%+v", err)
continue
}
//TODO: LOGIC CODE HERE
logger.Infof("rocketmq pull result:%#v", *cr)
logger.Info("msgList:", cr.GetMsgList())
logger.Info("messageQueue:", cr.GetMQ())
logger.Info("processQueue:", cr.GetPQ())
// pullConsumer.ACK(context.TODO(), cr,
consumer.ConsumeRetryLater)
pc.pullConsumer.ACK(ctx, cr, consumer.ConsumeSuccess)
}
}
--
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]