From 8d2a95fc0eeabe1b13d0a914c9ec2845d42c0be3 Mon Sep 17 00:00:00 2001
From: zhangzengfei <zhangzengfei@smartai.com>
Date: 星期四, 19 十月 2023 11:32:57 +0800
Subject: [PATCH] 添加主从serf切换事件
---
nsq/producer.go | 65 +++++++++++++++++---------------
1 files changed, 35 insertions(+), 30 deletions(-)
diff --git a/nsq/producer.go b/nsq/producer.go
index d7b80b2..516ed17 100644
--- a/nsq/producer.go
+++ b/nsq/producer.go
@@ -18,43 +18,48 @@
logx.Errorf("NewProducer err:%v", err)
return err
}
- // 娴嬭瘯鍙戝竷鏁版嵁
- //go func() {
- // for {
- // time.Sleep(time.Second)
- // _ = producer.Publish("test", []byte("123"))
- // }
- //}()
-
+ ////娴嬭瘯鍙戝竷鏁版嵁
//go func() {
// for {
// time.Sleep(time.Second * 2)
- // err := producer.Publish("aps.wangpengfei.erp.cstReply", []byte("456"))
- // logx.Infof("=====err:%v", err)
+ // _ = producer.Publish("test", []byte("123"))
// }
//}()
-
+ //
//go func() {
- // for {
- // time.Sleep(time.Second * 5)
- // applyMaterial := ApplyOrderMaterial{
- // FBillNo: "123",
- // FNumber: "456",
- // UseAmount: 1,
- // }
- //
- // applyBytes, err := json.Marshal([]*ApplyOrderMaterial{&applyMaterial})
- // if err != nil {
- // return
- // }
- //
- // producer := GetProducer()
- // err = producer.Publish(fmt.Sprintf("aps.%v.erp.cstApply", conf.WebConf.NodeId), applyBytes)
- // logx.Infof("===============ApplyMaterialByProduct topic:%v, applyBytes:%v, err:%v", fmt.Sprintf("aps.%v.erp.cstApply", conf.WebConf.NodeId), string(applyBytes), err)
- // if err != nil {
- // return
- // }
+ // testH := &testHand{}
+ // c, err := nsqclient.NewNsqConsumer(context.Background(), "test", "channel1")
+ // c.AddHandler(testH.HandleMessage)
+ // c.Run(conf.Conf.NsqConf.NsqdAddr, 1)
+ // if err != nil {
+ // return
+ // }
+ //}()
+ //go func() {
+ // testH := &testHand2{}
+ // c, err := nsqclient.NewNsqConsumer(context.Background(), "test", "channel2")
+ // c.AddHandler(testH.HandleMessage)
+ // c.Run(conf.Conf.NsqConf.NsqdAddr, 1)
+ // if err != nil {
+ // return
// }
//}()
return nil
}
+
+//// 娴嬭瘯娑堣垂鏁版嵁
+//type testHand struct {
+//}
+//
+//func (slf *testHand) HandleMessage(data []byte) (err error) {
+// fmt.Println("testHand1", string(data))
+// return err
+//}
+//
+//type testHand2 struct {
+//}
+//
+//func (slf *testHand2) HandleMessage(data []byte) (err error) {
+// fmt.Println("testHand2", string(data))
+// return err
+//}
--
Gitblit v1.8.0