diff --git a/consume/egg_energy_deal_user_virtual_coin_consume.go b/consume/egg_energy_deal_user_virtual_coin_consume.go index 625f736..874a465 100644 --- a/consume/egg_energy_deal_user_virtual_coin_consume.go +++ b/consume/egg_energy_deal_user_virtual_coin_consume.go @@ -53,7 +53,6 @@ func EggEnergyDealUserVirtualCoinDataConsume(queue md.MqQueue) { panic(errors.New("error getting message")) } } - fmt.Println("get msg done") } func handleEggEnergyDealUserVirtualCoinDataConsume(msgData []byte) error { diff --git a/consume/egg_energy_fund_data_consume.go b/consume/egg_energy_fund_data_consume.go index f4350e0..0898d01 100644 --- a/consume/egg_energy_fund_data_consume.go +++ b/consume/egg_energy_fund_data_consume.go @@ -57,7 +57,6 @@ func EggEnergyDealFundDataConsume(queue md.MqQueue) { panic(errors.New("error getting message")) } } - fmt.Println("get msg done") } func handleEggEnergyDealFundDataConsume(msgData []byte) error { diff --git a/consume/egg_energy_platform_revenue_data.go b/consume/egg_energy_platform_revenue_data.go index 2139714..f5cd933 100644 --- a/consume/egg_energy_platform_revenue_data.go +++ b/consume/egg_energy_platform_revenue_data.go @@ -57,7 +57,6 @@ func EggEnergyDealPlatformRevenueDataConsume(queue md.MqQueue) { panic(errors.New("error getting message")) } } - fmt.Println("get msg done") } func handleEggEnergyDealPlatformRevenueDataConsume(msgData []byte) error { diff --git a/consume/im_egg_energy_batch_send_message_consume.go b/consume/im_egg_energy_batch_send_message_consume.go index 39aaf1c..8127f5b 100644 --- a/consume/im_egg_energy_batch_send_message_consume.go +++ b/consume/im_egg_energy_batch_send_message_consume.go @@ -52,7 +52,6 @@ func IMEggEnergyBatchSendMessageDataConsume(queue md.MqQueue) { panic(errors.New("error getting message")) } } - fmt.Println("get msg done") } func handleIMEggEnergyBatchSendMessageDataConsume(msgData []byte) error { diff --git a/consume/im_egg_energy_del_friend_circle_comment_consume.go b/consume/im_egg_energy_del_friend_circle_comment_consume.go new file mode 100644 index 0000000..fa16e42 --- /dev/null +++ b/consume/im_egg_energy_del_friend_circle_comment_consume.go @@ -0,0 +1,77 @@ +package consume + +import ( + "applet/app/cfg" + utils2 "applet/app/utils" + "applet/app/utils/cache" + "applet/app/utils/logx" + "applet/consume/md" + "code.fnuoos.com/EggPlanet/egg_system_rules.git" + md3 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md" + md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md" + "code.fnuoos.com/go_rely_warehouse/zyos_go_es.git/es" + "code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit" + "encoding/json" + "errors" + "fmt" + "github.com/streadway/amqp" + "time" +) + +func IMEggEnergyDelFriendCircleDataConsume(queue md.MqQueue) { + fmt.Println(">>>>>>>>>>>>IMEggEnergyDelFriendCircleDataConsume>>>>>>>>>>>>") + ch, err := rabbit.Cfg.Pool.GetChannel() + if err != nil { + logx.Error(err) + return + } + defer ch.Release() + //1、将自己绑定到交换机上 + ch.Bind(queue.Name, queue.ExchangeName, queue.RoutKey) + //2、取出数据进行消费 + ch.Qos(1) + delivery := ch.Consume(queue.Name, false) + + egg_system_rules.Init(cfg.RedisAddr) + var res amqp.Delivery + var ok bool + for { + res, ok = <-delivery + if ok == true { + err = handleIMEggEnergyDelFriendCircleCommentDataConsume(res.Body) + if err != nil { + fmt.Println("IMEggEnergyDelFriendCircleDataConsume_ERR:::::", err.Error()) + utils2.FilePutContents("IMEggEnergyDelFriendCircleDataConsume_ERR", utils2.SerializeStr(map[string]interface{}{ + "body": res.Body, + "err": err.Error(), + })) + } + //_ = res.Reject(false) + err = res.Ack(true) + fmt.Println("err ::: ", err) + } else { + panic(errors.New("error getting message")) + } + } +} + +func handleIMEggEnergyDelFriendCircleCommentDataConsume(msgData []byte) error { + time.Sleep(time.Duration(100) * time.Millisecond) //休眠100毫秒 + // 1.解析mq中queue的数据结构体 + var msg *md2.IMEggEnergyStructForDelFriendCircleCommentData + err := json.Unmarshal(msgData, &msg) + if err != nil { + return err + } + + //1、删除es数据 + _, err = es.DeleteDoc(md3.EggFriendCircleCommentEsAlias, msg.CommentIndexId) + if err != nil { + return err + } + + //2、删除redis数据 + key := fmt.Sprintf(md3.CommentLikeCacheKey, msg.CommentIndexId) + cache.Del(key) + return nil +} diff --git a/consume/init.go b/consume/init.go index f10ce26..6e1604b 100644 --- a/consume/init.go +++ b/consume/init.go @@ -22,6 +22,7 @@ func initConsumes() { jobs[consumeMd.EggEnergyDealFundDataFunName] = EggEnergyDealFundDataConsume jobs[consumeMd.EggEnergyDealUserVirtualCoinDataFunName] = EggEnergyDealUserVirtualCoinDataConsume jobs[consumeMd.IMEggEnergyBatchSendMessageDataFunName] = IMEggEnergyBatchSendMessageDataConsume + jobs[consumeMd.IMEggEnergyDelFriendCircleDataFunName] = IMEggEnergyDelFriendCircleDataConsume } func Run() { diff --git a/consume/md/consume_key.go b/consume/md/consume_key.go index 4674cb4..538de92 100644 --- a/consume/md/consume_key.go +++ b/consume/md/consume_key.go @@ -45,7 +45,7 @@ var RabbitMqQueueKeyList = []*MqQueue{ IsPersistent: false, RoutKey: "deal_user_virtual_coin", BindKey: "", - ConsumeFunName: "EggEnergyDealUserVirtualCoinDataConsume", + ConsumeFunName: "EggEnergyDealUserVirtualCoinDataConsume ", }, { ExchangeName: "im.egg.energy", @@ -56,6 +56,15 @@ var RabbitMqQueueKeyList = []*MqQueue{ BindKey: "", ConsumeFunName: "IMEggEnergyBatchSendMessageDataConsume", }, + { + ExchangeName: "im.egg.energy", + Name: "im_egg_energy_del_friend_comment_circle_queue", + Type: DirectQueueType, + IsPersistent: false, + RoutKey: "del_friend_circle_comment_data", + BindKey: "", + ConsumeFunName: "IMEggEnergyDelFriendCircleDataConsume", + }, } const ( @@ -64,4 +73,5 @@ const ( EggEnergyDealPlatformRevenueDataFunName = "EggEnergyDealPlatformRevenueDataConsume" EggEnergyDealUserVirtualCoinDataFunName = "EggEnergyDealUserVirtualCoinDataConsume" IMEggEnergyBatchSendMessageDataFunName = "IMEggEnergyBatchSendMessageDataConsume" + IMEggEnergyDelFriendCircleDataFunName = "IMEggEnergyDelFriendCircleDataConsume" ) diff --git a/go.mod b/go.mod index 5e88ebe..4aa97af 100644 --- a/go.mod +++ b/go.mod @@ -35,6 +35,7 @@ require ( ) require ( + code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be // indirect filippo.io/edwards25519 v1.1.0 // indirect github.com/bytedance/sonic v1.11.3 // indirect github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d // indirect