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.
 
 
 

97 lines
3.6 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.ZhiosUserUpLvFunName] = ZhiosUserUpLv
  17. jobs[consumeMd.CanalGuideOrderByUserUpLvConsume] = CanalGuideOrderByUserUpLvConsume
  18. jobs[consumeMd.ZhiosOrderFreeFunName] = ZhiosOrderFree
  19. jobs[consumeMd.ZhiosOrderTotalFunName] = ZhiosOrderTotal
  20. jobs[consumeMd.ZhiosOrderTotalSecondFunName] = ZhiosOrderTotalSecond
  21. //
  22. jobs[consumeMd.ZhiosOrderSettleTotalFunName] = ZhiosSettleTotal
  23. jobs[consumeMd.ZhiosOrderHjyFunName] = ZhiosOrderHjy
  24. jobs[consumeMd.ZhiosOrderBuckleFunName] = ZhiosOrderBuckle
  25. //
  26. jobs[consumeMd.ZhiosSupplierAfterOrderFunName] = ZhiosSupplierAfterOrder
  27. jobs[consumeMd.ZhiosGuideStoreOrderFunName] = ZhiosGuideStoreOrder
  28. //jobs[consumeMd.ZhiosAppreciationDevFunName] = ZhiosAppreciation
  29. jobs[consumeMd.ZhiosAppreciationFunName] = ZhiosAppreciation
  30. jobs[consumeMd.ZhiosValidUserFunName] = ZhiosValidUser
  31. //jobs[consumeMd.ZhiosAcquisitionConditionDevFunName] = ZhiosAcquisitionCondition
  32. jobs[consumeMd.ZhiosAcquisitionConditionFunName] = ZhiosAcquisitionCondition
  33. jobs[consumeMd.CanalOrderConsumeFunName] = CanalOrderConsume
  34. jobs[consumeMd.CanalGuideOrderConsumeFunName] = CanalGuideOrderConsume
  35. jobs[consumeMd.ZhiOsUserVisitIpAddressConsumeFunName] = ZhiOsUserVisitIpAddressConsume
  36. jobs[consumeMd.DouShenUserRegisterConsumeForOfficialFunName] = DouShenUserRegisterConsumeForOfficial
  37. jobs[consumeMd.DouShenUserRegisterConsumeForOperationCenterFunName] = DouShenUserRegisterConsumeForOperationCenter
  38. jobs[consumeMd.DouShenUserRegisterConsumeForMyRecommenderFunName] = DouShenUserRegisterConsumeForMyRecommender
  39. jobs[consumeMd.DouShenUserRegisterConsumeForMyFansFunName] = DouShenUserRegisterConsumeForMyFans
  40. jobs[consumeMd.DouShenUserRegisterConsumeForUserRegisterUpLvFunName] = DouShenUserRegisterConsumeForUserRegisterUpLv
  41. jobs[consumeMd.ZhiosFastReturnOrderPayFunName] = ZhiosFastReturnOrderPay
  42. jobs[consumeMd.ZhiosFastReturnOrderSuccessFunName] = ZhiosFastReturnOrderSuccess
  43. jobs[consumeMd.ZhiosFastReturnOrderRefundFunName] = ZhiosFastReturnOrderRefund
  44. jobs[consumeMd.ZhiosFastReturnOrderRefundSecondFunName] = ZhiosFastReturnOrderRefundSecond
  45. //jobs[consumeMd.CanalMallOrdForYouMiShangFunName] = CanalMallOrdForYouMiShang
  46. jobs[consumeMd.YoumishangExchangeStoreFunName] = YoumishangExchangeStore
  47. jobs[consumeMd.ZhiosRechargeOrderFailFunName] = ZhiosRechargeOrderFail
  48. jobs[consumeMd.CloudIssuanceAsyncMLoginFunName] = CloudIssuanceAsyncMLoginConsume
  49. jobs[consumeMd.ZhiosTikTokUpdateFunName] = ZhiosTikTokUpdate
  50. jobs[consumeMd.ZhiosTikTokAllUpdateFunName] = ZhiosTikTokAllUpdate
  51. jobs[consumeMd.ZhiosCapitalPoolOrderTotalFunName] = ZhiosCapitalPoolOrderTotal
  52. jobs[consumeMd.ZhiosExpressOrderFail] = ZhiosExpressOrderFail
  53. jobs[consumeMd.ZhiosWithdrawReward] = ZhiosWithdrawReward
  54. //jobs[consumeMd.ZhiosRechargeOrderFailDevFunName] = ZhiosRechargeOrderFailDev
  55. jobs[consumeMd.CloudIssuanceMsgCallBackFunName] = CloudIssuanceMsgCallBackConsume
  56. }
  57. func Run() {
  58. for _, v := range consumeMd.RabbitMqQueueKeyList {
  59. if _, ok := jobs[v.ConsumeFunName]; ok {
  60. go doConsume(v.ConsumeFunName, *v)()
  61. }
  62. }
  63. }
  64. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  65. return func() {
  66. begin := time.Now().Local()
  67. jobs[fnName](queue)
  68. end := time.Now().Local()
  69. logx.Infof(
  70. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  71. fnName,
  72. begin.Format("2006-01-02 15:04:05.000"),
  73. end.Format("2006-01-02 15:04:05.000"),
  74. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  75. )
  76. }
  77. }