作者 唐旭辉

更新

@@ -135,6 +135,10 @@ func (r *Runer) Start(ctx context.Context) { @@ -135,6 +135,10 @@ func (r *Runer) Start(ctx context.Context) {
135 logs.Error(e) 135 logs.Error(e)
136 } 136 }
137 }() 137 }()
  138 + if len(r.msgConsumer.topics) == 0 {
  139 + logs.Error("there has no topics")
  140 + return
  141 + }
138 for { 142 for {
139 select { 143 select {
140 case <-ctx.Done(): 144 case <-ctx.Done():
@@ -4,7 +4,6 @@ import ( @@ -4,7 +4,6 @@ import (
4 "os" 4 "os"
5 5
6 "github.com/Shopify/sarama" 6 "github.com/Shopify/sarama"
7 - "github.com/astaxie/beego/logs"  
8 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/port/consumer/handles" 7 "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/port/consumer/handles"
9 ) 8 )
10 9
@@ -13,11 +12,11 @@ type TopicHandle func(*sarama.ConsumerMessage) error @@ -13,11 +12,11 @@ type TopicHandle func(*sarama.ConsumerMessage) error
13 12
14 //TopicHandleRouters 根据topic区分消息并进行处理 13 //TopicHandleRouters 根据topic区分消息并进行处理
15 var TopicHandleRouters = map[string]TopicHandle{ 14 var TopicHandleRouters = map[string]TopicHandle{
16 - "topic_test": func(message *sarama.ConsumerMessage) error {  
17 - logs.Info("Done Message claimed: timestamp = %v, topic = %s offset = %v value = %v \n",  
18 - message.Timestamp, message.Topic, message.Offset, string(message.Value))  
19 - return nil  
20 - }, 15 + // "topic_test": func(message *sarama.ConsumerMessage) error {
  16 + // logs.Info("Done Message claimed: timestamp = %v, topic = %s offset = %v value = %v \n",
  17 + // message.Timestamp, message.Topic, message.Offset, string(message.Value))
  18 + // return nil
  19 + // },
21 } 20 }
22 21
23 func init() { 22 func init() {