From 9bd4dc83742375ce3caa472b734f89471554161c Mon Sep 17 00:00:00 2001 From: xiaolipro <2357729423@qq.com> Date: Sat, 30 Aug 2025 16:11:48 +0800 Subject: [PATCH] kafka --- src/TrackCenter.Api/appsettings.json | 15 +++++++-------- .../TrackCenterApplicationModule.cs | 2 +- .../ES/ConnectionFactory.cs | 10 ++++++---- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/TrackCenter.Api/appsettings.json b/src/TrackCenter.Api/appsettings.json index 44f0ceed..e25d13cc 100644 --- a/src/TrackCenter.Api/appsettings.json +++ b/src/TrackCenter.Api/appsettings.json @@ -38,8 +38,8 @@ "Default": "server=129.204.22.146;database=track_center;uid=dev;pwd=itd!@#123;charset=utf8mb4;" }, "FeiShuNotice": { - "Title": "TrackCenter-Dev", - "Webhook": "https://open.feishu.cn/open-apis/bot/v2/hook/255c44ff-5891-4902-9b6a-6d0250e745f7", + "TitlePrefix": "TrackCenter-Dev", + "Webhook": "https://open.feishu.cn/open-apis/bot/v2/hook/e5ced977-a616-42ce-8684-c7628e71b35e", "Timeout": 20 }, "Redis": { @@ -60,15 +60,14 @@ } }, "ElasticSearch": { - "NodeUrls": [ - "http://129.204.22.146:9200" - ], + "NodeUrls": [ "http://129.204.22.146:9200" ], "LoginName": "elastic", - "Password": "afyTgmVb8jq6", - "Base64PassPassword": "Basic ZWxhc3RpYzphZnlUZ21WYjhqcTY=" + "Password": "itd!@#123", + "ShowLogInfo": false, + "IndexPrefix": "" }, "Kafka": { - "BootstrapServers": "kafka01.test.itfx.local:9092,kafka02.test.itfx.local:9092,kafka03.test.itfx.local:9092", + "BootstrapServers": "81.71.47.150:9192,81.71.47.150:9292,81.71.47.150:9392", "Consumer": { // 会话超时时间ms,超时时间未收到客户端心跳,则会移除该客户端同时触发自平衡 "SessionTimeoutMs": 45000, diff --git a/src/TrackCenter.Application/TrackCenterApplicationModule.cs b/src/TrackCenter.Application/TrackCenterApplicationModule.cs index 12bd198a..4e8e0cca 100644 --- a/src/TrackCenter.Application/TrackCenterApplicationModule.cs +++ b/src/TrackCenter.Application/TrackCenterApplicationModule.cs @@ -152,7 +152,7 @@ public class TrackCenterApplicationModule : FakeModule $",abortConnect=false"; // todo:注册预警计算服务 - //context.Services.AddWarningCalcServices(configuration); + context.Services.AddWarningCalcServices(configuration); // 注册预警任务后台服务 context.Services.AddHostedService(); diff --git a/src/TrackCenter.Repository/ES/ConnectionFactory.cs b/src/TrackCenter.Repository/ES/ConnectionFactory.cs index 5196fedd..eb51b82b 100644 --- a/src/TrackCenter.Repository/ES/ConnectionFactory.cs +++ b/src/TrackCenter.Repository/ES/ConnectionFactory.cs @@ -1,9 +1,12 @@ using System.Collections.Concurrent; +using System.Diagnostics; using System.Reflection; using Elasticsearch.Net; using Microsoft.Extensions.Logging; using Microsoft.Extensions.Options; using Nest; +using Serilog; +using TrackCenter.Domain.Extensions; namespace TrackCenter.Repository.ES; @@ -55,7 +58,7 @@ public class ConnectionFactory : ISingletonDependency _connectionSettings.DefaultIndex(defaultIndex); //是否输出日志 - if (_options.ShowLogInfo) + if (Debugger.IsAttached || _options.ShowLogInfo) { _connectionSettings.EnableDebugMode(); client = new ElasticClient(_connectionSettings @@ -63,8 +66,8 @@ public class ConnectionFactory : ISingletonDependency .DisableDirectStreaming() .OnRequestCompleted(apiCallDetails => { - string infos = GetInfosFromApiCallDetails(apiCallDetails); - Console.WriteLine($"{Environment.NewLine}{infos}{Environment.NewLine}"); + var infos = GetInfosFromApiCallDetails(apiCallDetails); + LogHelper.Info($"{Environment.NewLine}{infos}{Environment.NewLine}"); })); } else @@ -72,7 +75,6 @@ public class ConnectionFactory : ISingletonDependency client = new ElasticClient(_connectionSettings); } - _clientDic.TryAdd(type, client); return client;