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 713ba89  doc(readme): update orderly producer using new api
713ba89 is described below

commit 713ba898049749e517f2ab49165777404319b14b
Author: dinglei <[email protected]>
AuthorDate: Tue Nov 26 15:54:23 2019 +0800

    doc(readme): update orderly producer using new api
    
    doc(readme): update orderly producer using the new API.
---
 doc/Introduction.md | 69 ++++++++++++++++-------------------------------------
 1 file changed, 21 insertions(+), 48 deletions(-)

diff --git a/doc/Introduction.md b/doc/Introduction.md
index 60e70d8..55e8bd3 100644
--- a/doc/Introduction.md
+++ b/doc/Introduction.md
@@ -50,54 +50,27 @@ your could download directly or build manually:
     ```
 - Send ordered message
     ```go
-    type queueSelectorByOrderID struct{}
-
-    func (s queueSelectorByOrderID) Select(size int, m *rocketmq.Message, arg 
interface{}) int{
-       return arg.(int) % size
-    }
-    type worker struct {
-           p            rocketmq.Producer
-           leftMsgCount int64
-    }
-
-    func (w *worker) run() {
-           selector := queueSelectorByOrderID{}
-           for atomic.AddInt64(&w.leftMsgCount, -1) >= 0 {
-                   r, err := w.p.SendMessageOrderly(
-                           &rocketmq.Message{Topic: *topic, Body: *body}, 
selector, 7 /*orderID*/, 3,
-                   )
-                   if err != nil {
-                           println("Send Orderly Error:", err)
-                   }
-                   fmt.Printf("send orderly result:%+v\n", r)
-           }
-    }
-
-    func sendMessageOrderly(config *rocketmq.ProducerConfig) {
-           producer, err := rocketmq.NewProducer(config)
-           if err != nil {
-                   fmt.Println("create Producer failed, error:", err)
-                   return
-        }
-
-           producer.Start()
-           defer producer.Shutdown()
-
-           wg := sync.WaitGroup{}
-           wg.Add(*workerCount)
-
-           workers := make([]worker, *workerCount)
-           for i := range workers {
-                   workers[i].p = producer
-                   workers[i].leftMsgCount = (int64)(*amount)
-           }
-
-           for i := range workers {
-                   go func(w *worker) { w.run(); wg.Done() }(&workers[i])
-           }
-
-           wg.Wait()
-    }
+       func sendMessageOrderlyByShardingKey(config *rocketmq.ProducerConfig) {
+               producer, err := rocketmq.NewProducer(config)
+               if err != nil {
+                       fmt.Println("create Producer failed, error:", err)
+                       return
+               }
+
+               producer.Start()
+               defer producer.Shutdown()
+               for i := 0; i < 1000; i++ {
+                       msg := fmt.Sprintf("%s-%d", "Hello Lite Orderly 
Message", i)
+                       r, err := producer.SendMessageOrderlyByShardingKey(
+                               &rocketmq.Message{Topic: 
"YourOrderLyTopicXXXXXXXX", Body: msg}, "ShardingKey" /*orderID*/)
+                       if err != nil {
+                               println("Send Orderly Message Error:", err)
+                       }
+                       fmt.Printf("send orderly message result:%+v\n", r)
+                       time.Sleep(time.Duration(1) * time.Second)
+               }
+
+       }
     ```
 - Push Consumer
     ```go

Reply via email to