golang 的 rabbitmq 消费项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

79 rivejä
2.8 KiB

  1. package consume
  2. import (
  3. "applet/app/utils/logx"
  4. consumeMd "applet/consume/md"
  5. "time"
  6. )
  7. var (
  8. jobs = map[string]func(consumeMd.MqQueue){}
  9. )
  10. func Init() {
  11. // 初始化任务列表
  12. initConsumes()
  13. }
  14. // 增加消费任务队列
  15. func initConsumes() {
  16. jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
  17. //jobs[consumeMd.ZhiosAcquisitionConditionDevFunName] = ZhiosAcquisitionCondition
  18. jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
  19. jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
  20. jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
  21. jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
  22. jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
  23. jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
  24. jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
  25. jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
  26. jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
  27. jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
  28. jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
  29. jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
  30. jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
  31. //jobs[consumeMd.CanalMallOrdForYouMiShangFunName] = CanalMallOrdForYouMiShang
  32. jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
  33. jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
  34. jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
  35. jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
  36. jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
  37. jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
  38. jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
  39. jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
  40. //jobs[consumeMd.ZhiosRechargeOrderFailDevFunName] = ZhiosRechargeOrderFailDev
  41. }
  42. func Run() {
  43. for _, v := range consumeMd.RabbitMqQueueKeyList {
  44. if _, ok := jobs[v.ConsumeFunName]; ok {
  45. go doConsume(v.ConsumeFunName, *v)()
  46. }
  47. }
  48. }
  49. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  50. return func() {
  51. begin := time.Now().Local()
  52. jobs[fnName](queue)
  53. end := time.Now().Local()
  54. logx.Infof(
  55. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  56. fnName,
  57. begin.Format("2006-01-02 15:04:05.000"),
  58. end.Format("2006-01-02 15:04:05.000"),
  59. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  60. )
  61. }
  62. }