username@email.com
2024-09-09 626943b5ba84ce44bc19f4c3b8e8e94638bec733
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using CoreCms.Net.Configuration;
using CoreCms.Net.RedisMQ;
using InitQ;
using Microsoft.Extensions.DependencyInjection;
 
namespace CoreCms.Net.Core.Config
{
    /// <summary>
    /// Redis 消息队列 启动服务
    /// </summary>
    public static class RedisMessageQueueSetup
    {
        public static void AddRedisMessageQueueSetup(this IServiceCollection services)
        {
            if (services == null) throw new ArgumentNullException(nameof(services));
 
            services.AddInitQ(m =>
            {
                //没消息时挂起时长(毫秒)
                m.SuspendTime = 1000;
 
                //每次消费消息间隔时间(毫秒)
                m.IntervalTime = 1000;
 
                //redis服务器地址
                m.ConnectionString = AppSettingsConstVars.RedisConfigConnectionString;
                //对应的订阅者类,需要new一个实例对象,当然你也可以传参,比如日志对象
                m.ListSubscribe = new List<Type>() {
                    typeof(MessagePushSubscribe),
                    typeof(WeChatPayShippingSubscribe),
                    typeof(RefundSubscribe),
                    typeof(OrderAgentOrDistributionSubscribe),
                    typeof(OrderAutomaticDeliverySubscribe),
                    typeof(OrderFinishCommandSubscribe),
                    typeof(OrderPrintSubscribe),
                    typeof(UserSubscribe),
                    typeof(WeChatPayNoticeSubscribe),
                    typeof(SendWxTemplateMessageSubscribe),
                    typeof(AfterSalesReviewSubscribe),
                    typeof(AfterSalesReviewForPointSubscribe),
                    typeof(AliPayNoticeSubscribe),
                    typeof (DistributionAchievementMQ),
                     typeof(DistributionSendOderMQ),
                };
                //显示日志
                m.ShowLog = false;
            });
        }
    }
}