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 { /// /// Redis 消息队列 启动服务 /// 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() { 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; }); } } }