You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
1.3 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Admin.Core.Common;
using InitQ;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
namespace Admin.Core.Extensions
{
/// <summary>
/// Redis 消息队列 启动服务
/// </summary>
public static class RedisInitMqSetup
{
public static void AddRedisInitMqSetup(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
if (Appsettings.app(new string[] { "Startup", "RedisMq", "Enabled" }).ObjToBool())
{
//
services.AddInitQ(m =>
{
//时间间隔
m.SuspendTime = 2000;
//redis服务器地址
m.ConnectionString = Appsettings.app(new string[] { "Redis", "ConnectionString" });
//对应的订阅者类需要new一个实例对象当然你也可以传参比如日志对象
m.ListSubscribe = new List<Type>() {
typeof(RedisSubscribe),
typeof(RedisSubscribe2)
};
//显示日志
m.ShowLog = false;
});
}
}
}
}