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.
 
 
 

98 lines
3.7 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. jobs[consumeMd.SupplyCloudChainFenxiaoNewChangeFunName] = SupplyCloudChainFenxiaoNewChangeConsume
  57. }
  58. func Run() {
  59. for _, v := range consumeMd.RabbitMqQueueKeyList {
  60. if _, ok := jobs[v.ConsumeFunName]; ok {
  61. go doConsume(v.ConsumeFunName, *v)()
  62. }
  63. }
  64. }
  65. func doConsume(fnName string, queue consumeMd.MqQueue) func() {
  66. return func() {
  67. begin := time.Now().Local()
  68. jobs[fnName](queue)
  69. end := time.Now().Local()
  70. logx.Infof(
  71. "[%s] AutoConsume started at <%s>, ended at <%s> duration <%s>",
  72. fnName,
  73. begin.Format("2006-01-02 15:04:05.000"),
  74. end.Format("2006-01-02 15:04:05.000"),
  75. time.Duration(end.UnixNano()-begin.UnixNano()).String(),
  76. )
  77. }
  78. }