mirror of
https://gitee.com/ThingsGateway/ThingsGateway.git
synced 2025-10-30 23:24:00 +08:00
!71 适配远程客户端
This commit is contained in:
@@ -26,7 +26,32 @@ public partial class KafkaProducer : BusinessBaseWithCacheIntervalScriptAll
|
||||
public override VariablePropertyBase VariablePropertys => _variablePropertys;
|
||||
|
||||
protected override BusinessPropertyWithCacheIntervalScript _businessPropertyWithCacheIntervalScript => _driverPropertys;
|
||||
private IProducer<Null, byte[]> _producer;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return $" {nameof(KafkaProducer)} :{_driverPropertys.BootStrapServers}";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override Task DisposeAsync(bool disposing)
|
||||
{
|
||||
try
|
||||
{
|
||||
_producer?.Flush(TimeSpan.FromSeconds(10));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
_producer?.SafeDispose();
|
||||
return base.DisposeAsync(disposing);
|
||||
}
|
||||
|
||||
|
||||
#if !Management
|
||||
protected override async Task InitChannelAsync(IChannel? channel, CancellationToken cancellationToken)
|
||||
{
|
||||
#region 初始化
|
||||
@@ -66,28 +91,13 @@ public partial class KafkaProducer : BusinessBaseWithCacheIntervalScriptAll
|
||||
/// <inheritdoc/>
|
||||
public override bool IsConnected() => success;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public override string ToString()
|
||||
{
|
||||
return $" {nameof(KafkaProducer)} :{_driverPropertys.BootStrapServers}";
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
protected override Task DisposeAsync(bool disposing)
|
||||
{
|
||||
try
|
||||
{
|
||||
_producer?.Flush(TimeSpan.FromSeconds(10));
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
_producer?.SafeDispose();
|
||||
return base.DisposeAsync(disposing);
|
||||
}
|
||||
|
||||
protected override Task ProtectedExecuteAsync(object? state, CancellationToken cancellationToken)
|
||||
{
|
||||
return Update(cancellationToken);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ThingsGateway.Plugin.Kafka;
|
||||
/// </summary>
|
||||
public partial class KafkaProducer : BusinessBaseWithCacheIntervalScriptAll
|
||||
{
|
||||
private IProducer<Null, byte[]> _producer;
|
||||
#if !Management
|
||||
private ProducerBuilder<Null, byte[]> _producerBuilder;
|
||||
private ProducerConfig _producerconfig;
|
||||
private volatile bool producerSuccess = true;
|
||||
@@ -239,4 +239,7 @@ public partial class KafkaProducer : BusinessBaseWithCacheIntervalScriptAll
|
||||
}
|
||||
|
||||
#endregion 方法
|
||||
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\Gateway\ThingsGateway.Gateway.Application\ThingsGateway.Gateway.Application.csproj">
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Import Project="..\..\Version.props" />
|
||||
<Import Project="..\..\PackNuget.props" />
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>net8.0;</TargetFrameworks>
|
||||
|
||||
<DefineConstants>$(DefineConstants);Management</DefineConstants>
|
||||
<OutputPath>bin\$(Configuration)\Management\</OutputPath>
|
||||
<IntermediateOutputPath>obj\$(Configuration)\Management\$(TargetFramework)\</IntermediateOutputPath>
|
||||
<PackageOutputPath>$(MSBuildThisFileDirectory)..\..\..\..\nupkgs1</PackageOutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
<PropertyGroup>
|
||||
<AssemblyName>ThingsGateway.Plugin.Kafka</AssemblyName>
|
||||
<PackageId>$(MSBuildProjectName)</PackageId>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\PluginPro\ThingsGateway.Management.Razor\ThingsGateway.Management.Razor.csproj" />
|
||||
|
||||
<PackageReference Include="Confluent.Kafka" Version="2.11.0" GeneratePathProperty="true">
|
||||
<PrivateAssets>contentFiles;compile;build;buildMultitargeting;buildTransitive;analyzers;</PrivateAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Content Remove="Locales\*.json" />
|
||||
<EmbeddedResource Include="Locales\*.json">
|
||||
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
Reference in New Issue
Block a user