You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@rocketmq.apache.org by di...@apache.org on 2022/07/21 09:08:48 UTC
[rocketmq-client-go] branch master updated: fix: takeMessages sleep 5s when no msg (#629)
This is an automated email from the ASF dual-hosted git repository.
dinglei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-client-go.git
The following commit(s) were added to refs/heads/master by this push:
new b2bf873 fix: takeMessages sleep 5s when no msg (#629)
b2bf873 is described below
commit b2bf873c121a3a4ceff5838c9f6472337adefd8f
Author: Fei Yang <14...@qq.com>
AuthorDate: Thu Jul 21 17:08:42 2022 +0800
fix: takeMessages sleep 5s when no msg (#629)
https://github.com/apache/rocketmq-client-go/issues/628
---
consumer/process_queue.go | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/consumer/process_queue.go b/consumer/process_queue.go
index 76a9236..497b695 100644
--- a/consumer/process_queue.go
+++ b/consumer/process_queue.go
@@ -278,8 +278,13 @@ func (pq *processQueue) getMessages() []*primitive.MessageExt {
}
func (pq *processQueue) takeMessages(number int) []*primitive.MessageExt {
+ sleepCount := 0
for pq.msgCache.Empty() {
time.Sleep(10 * time.Millisecond)
+ if sleepCount > 500 {
+ return nil
+ }
+ sleepCount++
}
result := make([]*primitive.MessageExt, number)
i := 0