优化kafka服务订阅服务线程未启动完,立即重启容器导致资源错误问题
This commit is contained in:
parent
86da556e98
commit
679086b174
@ -8,10 +8,11 @@ using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace JiShe.CollectBus.Kafka.AdminClient;
|
||||
|
||||
public class AdminClientService : IAdminClientService, IDisposable, ISingletonDependency
|
||||
public class AdminClientService : IAdminClientService, ISingletonDependency
|
||||
{
|
||||
private readonly ILogger<AdminClientService> _logger;
|
||||
private readonly KafkaOptionConfig _kafkaOptionConfig;
|
||||
private readonly Lazy<IAdminClient> _lazyAdminClient;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="AdminClientService" /> class.
|
||||
/// </summary>
|
||||
@ -21,7 +22,8 @@ public class AdminClientService : IAdminClientService, IDisposable, ISingletonDe
|
||||
{
|
||||
_logger = logger;
|
||||
_kafkaOptionConfig = kafkaOptionConfig.Value;
|
||||
Instance = GetInstance();
|
||||
//Instance = GetInstance();
|
||||
_lazyAdminClient = new Lazy<IAdminClient>(() => GetInstance());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -30,7 +32,7 @@ public class AdminClientService : IAdminClientService, IDisposable, ISingletonDe
|
||||
/// <value>
|
||||
/// The instance.
|
||||
/// </value>
|
||||
public IAdminClient Instance { get; set; }
|
||||
public IAdminClient Instance => _lazyAdminClient.Value;
|
||||
|
||||
/// <summary>
|
||||
/// 创建Kafka主题
|
||||
@ -137,11 +139,6 @@ public class AdminClientService : IAdminClientService, IDisposable, ISingletonDe
|
||||
return metadata.Topics[0].Partitions.Count;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Instance?.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the instance.
|
||||
/// </summary>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user