增加了 用户会员过期队列

This commit is contained in:
2024-08-01 14:16:15 +08:00
parent 9d17c26ef5
commit 8094cd3c51
6 changed files with 211 additions and 2 deletions
+6
View File
@@ -21,6 +21,12 @@ func StartCron() {
panic("定时器启动失败:" + err.Error())
}
// 用户会员过期
_, err = c.AddFunc("0 0 0 * * *", crontab.UserMemberExpire)
if err != nil {
panic("定时器启动失败:" + err.Error())
}
// 启动定时任务调度器
c.Start()
+9
View File
@@ -49,6 +49,15 @@ func StartRabbitMqConsume() {
Handler: consumer.CancelUnPayOrder,
}
go startConsumer(s)
// 用户会员过期
s = rabbitMq.ConsumeS{
QueueName: "user.member.expired.delay.queue",
ExchangeName: "amqp.delay.direct",
RoutingKey: "UserMemberExpired",
Handler: consumer.UserMemberExpire,
}
go startConsumer(s)
}
// startConsumer 启动指定的消费者协程
+2 -2
View File
@@ -13,8 +13,8 @@ import (
func Redis() {
global.Redis = redis.NewClient(&redis.Options{
Addr: config.C.Redis.Host + ":" + strconv.Itoa(config.C.Redis.Port),
Password: config.C.Redis.Password, // no password set
DB: config.C.Redis.Db, // use default DB
Password: config.C.Redis.Password,
DB: config.C.Redis.Db,
PoolSize: config.C.Redis.PoolSize,
})
_, err := global.Redis.Ping(context.Background()).Result()