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 d3be7e5  a liitle improvement use chan instead (#854)
d3be7e5 is described below

commit d3be7e5bc01fdd9508916b463d6dac1043973d43
Author: hYang <[email protected]>
AuthorDate: Thu Jul 21 23:54:54 2022 +0800

    a liitle improvement use chan instead (#854)
---
 examples/consumer/simple/main.go | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/examples/consumer/simple/main.go b/examples/consumer/simple/main.go
index 70f35b3..8f21c0f 100644
--- a/examples/consumer/simple/main.go
+++ b/examples/consumer/simple/main.go
@@ -20,15 +20,14 @@ 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"
+       "os"
 )
 
 func main() {
+       sig := make(chan os.Signal)
        c, _ := rocketmq.NewPushConsumer(
                consumer.WithGroupName("testGroup"),
                
consumer.WithNsResolver(primitive.NewPassthroughResolver([]string{"127.0.0.1:9876"})),
@@ -50,7 +49,7 @@ func main() {
                fmt.Println(err.Error())
                os.Exit(-1)
        }
-       time.Sleep(time.Hour)
+       <-sig
        err = c.Shutdown()
        if err != nil {
                fmt.Printf("shutdown Consumer error: %s", err.Error())

Reply via email to