diff --git a/config.yaml b/config.yaml index cd1e1117..b5ff71e2 100644 --- a/config.yaml +++ b/config.yaml @@ -37,6 +37,8 @@ task: # MQ配置 mq: + # 是否启用 + enable: false # RabbitMQ配置 rabbitmq: host: 10.0.0.247 diff --git a/config/mq.go b/config/mq.go index caa73880..6bdf2f03 100644 --- a/config/mq.go +++ b/config/mq.go @@ -5,6 +5,7 @@ import "fmt" // mq // @description: MQ配置 type mq struct { + Enable bool `json:"enable" yaml:"enable"` // 是否启用 RabbitMQ rabbitMq `json:"rabbitmq" yaml:"rabbitmq"` // RabbitMQ配置 } diff --git a/mq/rabbitmq.go b/mq/rabbitmq.go index 3d4afe42..c5c1b63f 100644 --- a/mq/rabbitmq.go +++ b/mq/rabbitmq.go @@ -16,6 +16,10 @@ const exchangeName = "wechat-message" // Init // @description: 初始化MQ func Init() { + if !config.Conf.Mq.Enable { + log.Println("未启用MQ") + return + } // 读取MQ连接配置 mqUrl := config.Conf.Mq.RabbitMQ.GetURL() if mqUrl == "" {