This is an automated email from the ASF dual-hosted git repository.
aaronai pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/rocketmq-clients.git
The following commit(s) were added to refs/heads/master by this push:
new a52ffa40 golang: add error handling in simple consumer (#336)
a52ffa40 is described below
commit a52ffa408111e86064d9f958e919aa3c6fc6a6bc
Author: Lmonster <[email protected]>
AuthorDate: Wed Jan 4 12:17:37 2023 +0800
golang: add error handling in simple consumer (#336)
* fix (error): fix error handle in simple consumer
* feat (log): optim error log
* feat (simple consumer): remove getqueue in Unsubscribe
Co-authored-by: fuguoqiang <[email protected]>
---
golang/simple_consumer.go | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/golang/simple_consumer.go b/golang/simple_consumer.go
index 7b6342f5..220dd1e9 100644
--- a/golang/simple_consumer.go
+++ b/golang/simple_consumer.go
@@ -133,7 +133,11 @@ func (sc *defaultSimpleConsumer)
ChangeInvisibleDurationAsync(messageView *Messa
}
func (sc *defaultSimpleConsumer) Subscribe(topic string, filterExpression
*FilterExpression) error {
- sc.cli.getMessageQueues(context.Background(), topic)
+ _, err := sc.cli.getMessageQueues(context.Background(), topic)
+ if err != nil {
+ sc.cli.log.Errorf("subscribe error=%v with topic %s for
simpleConsumer", err, topic)
+ return err
+ }
sc.subscriptionExpressionsLock.Lock()
defer sc.subscriptionExpressionsLock.Unlock()
@@ -142,7 +146,6 @@ func (sc *defaultSimpleConsumer) Subscribe(topic string,
filterExpression *Filte
}
func (sc *defaultSimpleConsumer) Unsubscribe(topic string) error {
- sc.cli.getMessageQueues(context.Background(), topic)
sc.subscriptionExpressionsLock.Lock()
defer sc.subscriptionExpressionsLock.Unlock()