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 2019/01/10 14:50:15 UTC

[rocketmq-client-go] branch master updated: fix:The specified topic does not take effect when run the command:go run main.go produce/consume (#26)

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 9d20d66  fix:The specified topic does not take effect when run the command:go run main.go produce/consume (#26)
9d20d66 is described below

commit 9d20d660cba2048a29c442db527cfec2796bf1fa
Author: lemonzone2010 <le...@163.com>
AuthorDate: Thu Jan 10 22:50:08 2019 +0800

    fix:The specified topic does not take effect when run the command:go run main.go produce/consume (#26)
---
 examples/producer.go      | 2 +-
 examples/push_consumer.go | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/examples/producer.go b/examples/producer.go
index 01e8105..e1c4d2f 100644
--- a/examples/producer.go
+++ b/examples/producer.go
@@ -40,7 +40,7 @@ func sendMessage(config *rocketmq.ProducerConfig) {
 	fmt.Printf("Producer: %s started... \n", producer)
 	for i := 0; i < *amount; i++ {
 		msg := fmt.Sprintf("%s-%d", *body, i)
-		result, err := producer.SendMessageSync(&rocketmq.Message{Topic: "test", Body: msg})
+		result, err := producer.SendMessageSync(&rocketmq.Message{Topic: *topic, Body: msg})
 		if err != nil {
 			fmt.Println("Error:", err)
 		}
diff --git a/examples/push_consumer.go b/examples/push_consumer.go
index 723e32f..38e434c 100644
--- a/examples/push_consumer.go
+++ b/examples/push_consumer.go
@@ -34,7 +34,7 @@ func ConsumeWithPush(config *rocketmq.PushConsumerConfig) {
 	ch := make(chan interface{})
 	var count = (int64)(*amount)
 	// MUST subscribe topic before consumer started.
-	consumer.Subscribe("test", "*", func(msg *rocketmq.MessageExt) rocketmq.ConsumeStatus {
+	consumer.Subscribe(*topic, "*", func(msg *rocketmq.MessageExt) rocketmq.ConsumeStatus {
 		fmt.Printf("A message received: \"%s\" \n", msg.Body)
 		if atomic.AddInt64(&count, -1) <= 0 {
 			ch <- "quit"