mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-20 10:50:48 +08:00
配置最大连接数
This commit is contained in:
@@ -15,6 +15,7 @@ using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
using ThingsGateway.NewLife.Caching;
|
||||
using ThingsGateway.NewLife.Log;
|
||||
|
||||
namespace ThingsGateway.Logging;
|
||||
|
||||
@@ -33,7 +34,7 @@ public sealed class DatabaseLoggerProvider : ILoggerProvider, ISupportExternalSc
|
||||
/// <summary>
|
||||
/// 日志消息队列(线程安全)
|
||||
/// </summary>
|
||||
private readonly BlockingCollection<LogMessage> _logMessageQueue = new(12000);
|
||||
private readonly BlockingCollection<LogMessage> _logMessageQueue = new(20000);
|
||||
|
||||
/// <summary>
|
||||
/// 日志作用域提供器
|
||||
@@ -135,7 +136,10 @@ public sealed class DatabaseLoggerProvider : ILoggerProvider, ISupportExternalSc
|
||||
{
|
||||
try
|
||||
{
|
||||
_logMessageQueue.Add(logMsg);
|
||||
if (!_logMessageQueue.TryAdd(logMsg,5000))
|
||||
{
|
||||
XTrace.Log.Warn($"{nameof(DatabaseLoggerProvider)} queue add fail");
|
||||
}
|
||||
return;
|
||||
}
|
||||
catch (InvalidOperationException) { }
|
||||
|
@@ -14,6 +14,7 @@ using Microsoft.Extensions.Logging;
|
||||
using System.Collections.Concurrent;
|
||||
|
||||
using ThingsGateway.NewLife.Caching;
|
||||
using ThingsGateway.NewLife.Log;
|
||||
|
||||
namespace ThingsGateway.Logging;
|
||||
|
||||
@@ -32,7 +33,7 @@ public sealed class FileLoggerProvider : ILoggerProvider, ISupportExternalScope
|
||||
/// <summary>
|
||||
/// 日志消息队列(线程安全)
|
||||
/// </summary>
|
||||
private readonly BlockingCollection<LogMessage> _logMessageQueue = new(12000);
|
||||
private readonly BlockingCollection<LogMessage> _logMessageQueue = new(20000);
|
||||
|
||||
/// <summary>
|
||||
/// 日志作用域提供器
|
||||
@@ -170,8 +171,10 @@ public sealed class FileLoggerProvider : ILoggerProvider, ISupportExternalScope
|
||||
{
|
||||
try
|
||||
{
|
||||
_logMessageQueue.Add(logMsg);
|
||||
return;
|
||||
if (!_logMessageQueue.TryAdd(logMsg,5000))
|
||||
{
|
||||
XTrace.Log.Warn($"{nameof(DatabaseLoggerProvider)} queue add fail");
|
||||
}
|
||||
}
|
||||
catch (InvalidOperationException) { }
|
||||
catch { }
|
||||
|
@@ -76,7 +76,7 @@ internal sealed partial class SchedulerFactory : ISchedulerFactory
|
||||
/// <summary>
|
||||
/// 作业持久化记录消息队列(线程安全)
|
||||
/// </summary>
|
||||
private readonly BlockingCollection<PersistenceContext> _persistenceMessageQueue = new(12000);
|
||||
private readonly BlockingCollection<PersistenceContext> _persistenceMessageQueue = new(20000);
|
||||
|
||||
/// <summary>
|
||||
/// 不受控的作业 Id 集合
|
||||
|
@@ -85,6 +85,7 @@ public static class ChannelOptionsExtensions
|
||||
channelOptions.ThrowIfNull(nameof(IChannelOptions));
|
||||
var channelType = channelOptions.ChannelType;
|
||||
channelType.ThrowIfNull(nameof(ChannelTypeEnum));
|
||||
config.SetMaxCount(channelOptions.MaxClientCount);
|
||||
switch (channelType)
|
||||
{
|
||||
case ChannelTypeEnum.TcpClient:
|
||||
|
Reference in New Issue
Block a user