fix:redis init
This commit is contained in:
parent
de0d2f300f
commit
625846967b
@ -101,7 +101,7 @@ public class TrackPullService : ApplicationServiceBase
|
||||
if (input.Options == OptionTypeNoNull.修改) isAnyExp = isAnyExp.And(x => x.Id != input.Id);
|
||||
|
||||
if (await _trackPullConfigRepository.IsAnyAsync(isAnyExp))
|
||||
throw new BusinessException("配置不存在");
|
||||
throw new BusinessException("配置已经存在");
|
||||
}
|
||||
|
||||
switch (input.Options)
|
||||
|
||||
@ -1,11 +1,15 @@
|
||||
using System.Diagnostics;
|
||||
using System.Net;
|
||||
using DotNetCore.CAP;
|
||||
using DotNetCore.CAP.Internal;
|
||||
using DotNetCore.CAP.Messages;
|
||||
using Fake;
|
||||
using Fake.AspNetCore;
|
||||
using Fake.EventBus.RabbitMQ;
|
||||
using Fake.Modularity;
|
||||
using Fake.ObjectMapping.AutoMapper;
|
||||
using Fake.RabbitMQ;
|
||||
using FreeRedis;
|
||||
using Hangfire;
|
||||
using Hangfire.Redis.StackExchange;
|
||||
using InterfaceForward.Domain.Shared.Helpers;
|
||||
@ -39,9 +43,10 @@ public class TrackCenterApplicationModule : FakeModule
|
||||
|
||||
var rabbitOptions = configuration.GetSection("RabbitMQ").Get<FakeRabbitMqOptions>()!.Default;
|
||||
|
||||
//CAP
|
||||
#region CAP
|
||||
|
||||
context.Services.AddSingleton<ISubscribeExecutor, MySubscribeExecutor>();
|
||||
if (!System.Diagnostics.Debugger.IsAttached)
|
||||
if (!Debugger.IsAttached)
|
||||
{
|
||||
context.Services.AddCap(options =>
|
||||
{
|
||||
@ -71,7 +76,7 @@ public class TrackCenterApplicationModule : FakeModule
|
||||
{
|
||||
LogHelper.Error($@"
|
||||
|-CAP失败回调事件:
|
||||
|-处理类型:{(faileCalback.MessageType == DotNetCore.CAP.Messages.MessageType.Subscribe ? "消费消息达到最大重试次数,需要开发人员介入" : "生产消息推送失败")}
|
||||
|-处理类型:{(faileCalback.MessageType == MessageType.Subscribe ? "消费消息达到最大重试次数,需要开发人员介入" : "生产消息推送失败")}
|
||||
|-头部信息:{faileCalback.Message.Headers.ToJson()}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
@ -93,6 +98,13 @@ public class TrackCenterApplicationModule : FakeModule
|
||||
LogHelper.Info("-- 当前为本地环境,用内存存储和内存队列");
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
var options = configuration.GetSection("Redis").Get<ConnectionStringBuilder>();
|
||||
if (options == null)
|
||||
throw new FakeException("未找到Redis相关配置,请检查配置文件中是否包含名为Redis的节点");
|
||||
RedisHelper.Init(options, showLogInfo: Debugger.IsAttached);
|
||||
|
||||
context.Services.AddHostedService<RabbitClient>();
|
||||
context.Services.Configure<RabbitOptions>(options =>
|
||||
{
|
||||
@ -151,7 +163,7 @@ public class TrackCenterApplicationModule : FakeModule
|
||||
$",defaultDatabase={configuration["Redis:Database"]}" +
|
||||
$",abortConnect=false";
|
||||
|
||||
// todo:注册预警计算服务
|
||||
// 注册预警计算服务
|
||||
context.Services.AddWarningCalcServices(configuration);
|
||||
|
||||
// 注册预警任务后台服务
|
||||
|
||||
@ -12,7 +12,7 @@ public static class RedisHelper
|
||||
|
||||
#region 初始化方法
|
||||
|
||||
internal static void Init(ConnectionStringBuilder options, bool showLogInfo)
|
||||
public static void Init(ConnectionStringBuilder options, bool showLogInfo)
|
||||
{
|
||||
Options = options;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user