diff --git a/src/JT808.Gateway.Abstractions/IJT808NormalGatewayBuilder.cs b/src/JT808.Gateway.Abstractions/IJT808NormalGatewayBuilder.cs deleted file mode 100644 index 3608e8b..0000000 --- a/src/JT808.Gateway.Abstractions/IJT808NormalGatewayBuilder.cs +++ /dev/null @@ -1,13 +0,0 @@ -using JT808.Protocol; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Text; - -namespace JT808.Gateway.Abstractions -{ - public interface IJT808NormalGatewayBuilder: IJT808GatewayBuilder - { - - } -} diff --git a/src/JT808.Gateway.Abstractions/IJT808QueueGatewayBuilder.cs b/src/JT808.Gateway.Abstractions/IJT808QueueGatewayBuilder.cs deleted file mode 100644 index 1fb8a93..0000000 --- a/src/JT808.Gateway.Abstractions/IJT808QueueGatewayBuilder.cs +++ /dev/null @@ -1,13 +0,0 @@ -using JT808.Protocol; -using Microsoft.Extensions.DependencyInjection; -using System; -using System.Collections.Generic; -using System.Text; - -namespace JT808.Gateway.Abstractions -{ - public interface IJT808QueueGatewayBuilder: IJT808GatewayBuilder - { - - } -} diff --git a/src/JT808.Gateway.Abstractions/IJT808ReplyMessageHandler.cs b/src/JT808.Gateway.Abstractions/IJT808ReplyMessageHandler.cs new file mode 100644 index 0000000..176308c --- /dev/null +++ b/src/JT808.Gateway.Abstractions/IJT808ReplyMessageHandler.cs @@ -0,0 +1,21 @@ +using JT808.Protocol; +using JT808.Protocol.Enums; +using JT808.Protocol.Extensions; +using JT808.Protocol.MessageBody; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Gateway.Abstractions +{ + public interface IJT808ReplyMessageHandler + { + /// + /// + /// + /// 请求数据 + /// 当前会话 + /// 应答消息数据 + public byte[] Processor(string TerminalNo, byte[] Data); + } +} diff --git a/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj b/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj index aedca9b..3294e7d 100644 --- a/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj +++ b/src/JT808.Gateway.Abstractions/JT808.Gateway.Abstractions.csproj @@ -29,7 +29,6 @@ - diff --git a/src/JT808.Gateway.Abstractions/JT808NormalReplyMessageHandler.cs b/src/JT808.Gateway.Abstractions/JT808NormalReplyMessageHandler.cs deleted file mode 100644 index fbdfa71..0000000 --- a/src/JT808.Gateway.Abstractions/JT808NormalReplyMessageHandler.cs +++ /dev/null @@ -1,331 +0,0 @@ -using JT808.Protocol; -using JT808.Protocol.Enums; -using JT808.Protocol.Extensions; -using JT808.Protocol.MessageBody; -using System; -using System.Collections.Generic; -using System.Text; - -namespace JT808.Gateway.Abstractions -{ - public class JT808NormalReplyMessageHandler - { - protected Dictionary HandlerDict { get; } - - protected delegate byte[] MsgIdMethodDelegate(JT808HeaderPackage package, IJT808Session session); - protected JT808Serializer JT808Serializer { get; } - public JT808NormalReplyMessageHandler( - IJT808Config jT808Config) - { - this.JT808Serializer = jT808Config.GetSerializer(); - HandlerDict = new Dictionary { - {JT808MsgId.终端通用应答.ToUInt16Value(), Msg0x0001}, - {JT808MsgId.终端鉴权.ToUInt16Value(), Msg0x0102}, - {JT808MsgId.终端心跳.ToUInt16Value(), Msg0x0002}, - {JT808MsgId.终端注销.ToUInt16Value(), Msg0x0003}, - {JT808MsgId.终端注册.ToUInt16Value(), Msg0x0100}, - {JT808MsgId.位置信息汇报.ToUInt16Value(),Msg0x0200 }, - {JT808MsgId.定位数据批量上传.ToUInt16Value(),Msg0x0704 }, - {JT808MsgId.数据上行透传.ToUInt16Value(),Msg0x0900 }, - {JT808MsgId.查询服务器时间请求.ToUInt16Value(),Msg0x0004 }, - {JT808MsgId.查询终端参数应答.ToUInt16Value(),Msg0x0104 }, - {JT808MsgId.查询终端属性应答.ToUInt16Value(),Msg0x0107 }, - {JT808MsgId.终端升级结果通知.ToUInt16Value(),Msg0x0108 }, - {JT808MsgId.位置信息查询应答.ToUInt16Value(),Msg0x0201 }, - {JT808MsgId.链路检测.ToUInt16Value(),Msg0x8204 }, - {JT808MsgId.车辆控制应答.ToUInt16Value(),Msg0x0500 }, - {JT808MsgId.摄像头立即拍摄命令.ToUInt16Value(),Msg0x8801 }, - {JT808MsgId.多媒体数据上传.ToUInt16Value(),Msg0x0801 }, - {JT808MsgId.多媒体事件信息上传.ToUInt16Value(),Msg0x0800 }, - {JT808MsgId.CAN总线数据上传.ToUInt16Value(),Msg0x0705 }, - }; - } - - /// - /// - /// - /// 请求数据 - /// 当前会话 - /// 应答消息数据 - public virtual byte[] Processor(JT808HeaderPackage request, IJT808Session session) - { - if (HandlerDict.TryGetValue(request.Header.MsgId, out var func)) - { - return func(request, session); - } - else - { - //处理不了的消息统一回复通用应答 - return CommonReply(request, session); - } - } - /// - /// 终端通用应答 - /// 平台无需回复 - /// 实现自己的业务 - /// - /// - /// - public virtual byte[] Msg0x0001(JT808HeaderPackage request, IJT808Session session) - { - return default; - } - /// - /// 平台通用应答 - /// - /// - /// - public virtual byte[] CommonReply(JT808HeaderPackage request, IJT808Session session) - { - if (request.Version == JT808Version.JTT2019) - { - byte[] data = JT808Serializer.Serialize(JT808MsgId.平台通用应答.Create_平台通用应答_2019(request.Header.TerminalPhoneNo, new JT808_0x8001() - { - AckMsgId = request.Header.MsgId, - JT808PlatformResult = JT808PlatformResult.成功, - MsgNum = request.Header.MsgNum - })); - session.SendAsync(data); - return data; - } - else - { - byte[] data = JT808Serializer.Serialize(JT808MsgId.平台通用应答.Create(request.Header.TerminalPhoneNo, new JT808_0x8001() - { - AckMsgId = request.Header.MsgId, - JT808PlatformResult = JT808PlatformResult.成功, - MsgNum = request.Header.MsgNum - })); - session.SendAsync(data); - return data; - } - } - /// - /// 终端心跳 - /// - /// - /// - public virtual byte[] Msg0x0002(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// 查询服务器时间 - /// 2019版本 - /// - /// - /// - /// - public virtual byte[] Msg0x0004(JT808HeaderPackage request, IJT808Session session) - { - byte[] data = JT808Serializer.Serialize(JT808MsgId.查询服务器时间应答.Create(request.Header.TerminalPhoneNo, new JT808_0x8004() - { - Time=DateTime.Now - })); - session.SendAsync(data); - return data; - } - /// - /// 服务器补传分包请求 - /// - /// - /// - /// - public virtual byte[] Msg0x8003(JT808HeaderPackage request, IJT808Session session) - { - throw new NotImplementedException("0x8003-服务器补传分包请求"); - } - /// - /// 终端补传分包请求 - /// - /// - /// - /// - public virtual byte[] Msg0x0005(JT808HeaderPackage request, IJT808Session session) - { - throw new NotImplementedException("0x0005-终端补传分包请求"); - } - /// - /// 终端注册 - /// - /// - /// - /// - public virtual byte[] Msg0x0100(JT808HeaderPackage request, IJT808Session session) - { - if (request.Version == JT808Version.JTT2019) - { - byte[] data = JT808Serializer.Serialize(JT808MsgId.终端注册应答.Create_终端注册应答_2019(request.Header.TerminalPhoneNo, new JT808_0x8100() - { - Code = "J" + request.Header.TerminalPhoneNo, - JT808TerminalRegisterResult = JT808TerminalRegisterResult.成功, - AckMsgNum = request.Header.MsgNum - })); - session.SendAsync(data); - return data; - } - else - { - byte[] data = JT808Serializer.Serialize(JT808MsgId.终端注册应答.Create(request.Header.TerminalPhoneNo, new JT808_0x8100() - { - Code = "J" + request.Header.TerminalPhoneNo, - JT808TerminalRegisterResult = JT808TerminalRegisterResult.成功, - AckMsgNum = request.Header.MsgNum - })); - session.SendAsync(data); - return data; - } - } - /// - /// 终端注销 - /// - /// - /// - /// - public virtual byte[] Msg0x0003(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// 终端鉴权 - /// - /// - /// - /// - public virtual byte[] Msg0x0102(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// 查询终端参数应答 - /// - /// - /// - /// - public virtual byte[] Msg0x0104(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// 查询终端属性应答 - /// - /// - /// - /// - public virtual byte[] Msg0x0107(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// 终端升级结果应答 - /// - /// - /// - /// - public virtual byte[] Msg0x0108(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// 位置信息汇报 - /// - /// - /// - /// - public virtual byte[] Msg0x0200(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// 位置信息查询应答 - /// - /// - /// - /// - public virtual byte[] Msg0x0201(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// 链路检测 - /// 2019版本 - /// - /// - /// - /// - public virtual byte[] Msg0x8204(JT808HeaderPackage request, IJT808Session session) - { - return default; - } - /// - /// 车辆控制应答 - /// - /// - /// - /// - public virtual byte[] Msg0x0500(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// 定位数据批量上传 - /// - /// - /// - /// - public virtual byte[] Msg0x0704(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// CAN总线数据上传 - /// - /// - /// - /// - public virtual byte[] Msg0x0705(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// 多媒体事件信息上传 - /// - /// - /// - /// - public virtual byte[] Msg0x0800(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - /// - /// 多媒体数据上传 - /// - /// - /// - /// - public virtual byte[] Msg0x0801(JT808HeaderPackage request, IJT808Session session) - { - throw new NotImplementedException("0x8800多媒体数据上传应答"); - } - /// - /// 摄像头立即拍摄命令 - /// - /// - /// - /// - public virtual byte[] Msg0x8801(JT808HeaderPackage request, IJT808Session session) - { - throw new NotImplementedException("0x0805摄像头立即拍摄命令应答"); - } - /// - /// 数据上行透传 - /// - /// - /// - /// - public virtual byte[] Msg0x0900(JT808HeaderPackage request, IJT808Session session) - { - return CommonReply(request, session); - } - } -} diff --git a/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs b/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs index 94c64b1..1606b89 100644 --- a/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs +++ b/src/JT808.Gateway.Benchmark/JT808.Gateway.CleintBenchmark/Services/CleintBenchmarkHostedService.cs @@ -34,7 +34,7 @@ namespace JT808.Gateway.CleintBenchmark.Services { this.jT808TcpClientFactory = jT808TcpClientFactory; clientBenchmarkOptions = clientBenchmarkOptionsAccessor.Value; - logger = loggerFactory.CreateLogger("CleintBenchmarkHostedService"); + logger = loggerFactory.CreateLogger(); } public Task StartAsync(CancellationToken cancellationToken) diff --git a/src/JT808.Gateway.Client/JT808TcpClient.cs b/src/JT808.Gateway.Client/JT808TcpClient.cs index c5db80e..f2c3860 100644 --- a/src/JT808.Gateway.Client/JT808TcpClient.cs +++ b/src/JT808.Gateway.Client/JT808TcpClient.cs @@ -36,7 +36,7 @@ namespace JT808.Gateway.Client SendAtomicCounterService = serviceProvider.GetRequiredService(); ReceiveAtomicCounterService = serviceProvider.GetRequiredService(); JT808Serializer = serviceProvider.GetRequiredService().GetSerializer(); - Logger = serviceProvider.GetRequiredService().CreateLogger("JT808TcpClient"); + Logger = serviceProvider.GetRequiredService().CreateLogger(); } public async ValueTask ConnectAsync(EndPoint remoteEndPoint) { diff --git a/src/JT808.Gateway.Client/Services/JT808ReportHostedService.cs b/src/JT808.Gateway.Client/Services/JT808ReportHostedService.cs index 4d51096..34e48c4 100644 --- a/src/JT808.Gateway.Client/Services/JT808ReportHostedService.cs +++ b/src/JT808.Gateway.Client/Services/JT808ReportHostedService.cs @@ -28,7 +28,7 @@ namespace JT808.Gateway.Client.Services JT808SendAtomicCounterService jT808SendAtomicCounterService, IJT808TcpClientFactory jT808TcpClientFactory) { - logger = loggerFactory.CreateLogger("JT808ReportHostedService"); + logger = loggerFactory.CreateLogger(); jT808ReportOptions = jT808ReportOptionsAccessor; jT808ReportOptions.CurrentValue.FileExistsAndCreate(); this.jT808ReceiveAtomicCounterService = jT808ReceiveAtomicCounterService; diff --git a/src/JT808.Gateway.Kafka/Configs/JT808MsgReplyLoggingConsumerConfig.cs b/src/JT808.Gateway.Kafka/Configs/JT808MsgReplyLoggingConsumerConfig.cs new file mode 100644 index 0000000..62ac21a --- /dev/null +++ b/src/JT808.Gateway.Kafka/Configs/JT808MsgReplyLoggingConsumerConfig.cs @@ -0,0 +1,13 @@ +using Confluent.Kafka; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Gateway.Configs.Kafka +{ + public class JT808MsgReplyLoggingConsumerConfig : JT808ConsumerConfig, IOptions + { + JT808MsgReplyLoggingConsumerConfig IOptions.Value => this; + } +} diff --git a/src/JT808.Gateway.Kafka/Configs/JT808MsgReplyLoggingProducerConfig.cs b/src/JT808.Gateway.Kafka/Configs/JT808MsgReplyLoggingProducerConfig.cs new file mode 100644 index 0000000..3c14b45 --- /dev/null +++ b/src/JT808.Gateway.Kafka/Configs/JT808MsgReplyLoggingProducerConfig.cs @@ -0,0 +1,13 @@ +using Confluent.Kafka; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Text; + +namespace JT808.Gateway.Configs.Kafka +{ + public class JT808MsgReplyLoggingProducerConfig : JT808ProducerConfig, IOptions + { + JT808MsgReplyLoggingProducerConfig IOptions.Value => this; + } +} diff --git a/src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj b/src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj index b3204f2..79ce31c 100644 --- a/src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj +++ b/src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.csproj @@ -19,13 +19,14 @@ 基于Kafka的JT808消息发布与订阅 $(JT808GatewayPackageVersion) + + JT808.Gateway.Kafka.xml + + + JT808.Gateway.Kafka.xml + - - - - - diff --git a/src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.xml b/src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.xml new file mode 100644 index 0000000..b0c6f21 --- /dev/null +++ b/src/JT808.Gateway.Kafka/JT808.Gateway.Kafka.xml @@ -0,0 +1,80 @@ + + + + JT808.Gateway.Kafka + + + + + + + + GetSection("JT808MsgConsumerConfig") + + + + + + + + GetSection("JT808MsgReplyProducerConfig") + + + + + + + + GetSection("JT808MsgReplyConsumerConfig") + + + + + + + + GetSection("JT808MsgReplyLoggingConsumerConfig") + + + + + + + + GetSection("JT808SessionConsumerConfig") + + + + + + + + GetSection("JT808MsgProducerConfig") + + + + + + + + GetSection("JT808MsgReplyConsumerConfig") + + + + + + + + GetSection("JT808SessionProducerConfig") + + + + + + + + GetSection("JT808MsgReplyLoggingProducerConfig") + + + + diff --git a/src/JT808.Gateway.Kafka/JT808ClientKafkaExtensions.cs b/src/JT808.Gateway.Kafka/JT808ClientKafkaExtensions.cs index 754c401..9a9d0d8 100644 --- a/src/JT808.Gateway.Kafka/JT808ClientKafkaExtensions.cs +++ b/src/JT808.Gateway.Kafka/JT808ClientKafkaExtensions.cs @@ -41,7 +41,7 @@ namespace JT808.Gateway.Kafka /// /// /// - /// + /// /// GetSection("JT808MsgReplyConsumerConfig") /// public static IJT808ClientBuilder AddMsgReplyConsumer(this IJT808ClientBuilder jT808ClientBuilder, IConfiguration configuration) @@ -53,6 +53,18 @@ namespace JT808.Gateway.Kafka /// /// /// + /// + /// GetSection("JT808MsgReplyLoggingConsumerConfig") + /// + public static IJT808ClientBuilder AddMsgReplyLoggingConsumer(this IJT808ClientBuilder jT808ClientBuilder, IConfiguration configuration) + { + jT808ClientBuilder.JT808Builder.Services.Configure(configuration.GetSection("JT808MsgReplyLoggingConsumerConfig")); + jT808ClientBuilder.JT808Builder.Services.TryAddSingleton(); + return jT808ClientBuilder; + } + /// + /// + /// /// /// GetSection("JT808SessionConsumerConfig") /// diff --git a/src/JT808.Gateway.Kafka/JT808MsgConsumer.cs b/src/JT808.Gateway.Kafka/JT808MsgConsumer.cs index 62a696f..b4b184f 100644 --- a/src/JT808.Gateway.Kafka/JT808MsgConsumer.cs +++ b/src/JT808.Gateway.Kafka/JT808MsgConsumer.cs @@ -28,7 +28,7 @@ namespace JT808.Gateway.Kafka { consumer = new ConsumerBuilder(consumerConfigAccessor.Value).Build(); TopicName = consumerConfigAccessor.Value.TopicName; - logger = loggerFactory.CreateLogger("JT808MsgConsumer"); + logger = loggerFactory.CreateLogger(); } public void OnMessage(Action<(string TerminalNo, byte[] Data)> callback) diff --git a/src/JT808.Gateway.Kafka/JT808MsgReplyLoggingConsumer.cs b/src/JT808.Gateway.Kafka/JT808MsgReplyLoggingConsumer.cs new file mode 100644 index 0000000..7d997f9 --- /dev/null +++ b/src/JT808.Gateway.Kafka/JT808MsgReplyLoggingConsumer.cs @@ -0,0 +1,103 @@ +using Confluent.Kafka; +using JT808.Gateway.Configs.Kafka; +using JT808.Gateway.Abstractions; +using Microsoft.Extensions.Logging; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Threading.Tasks; + +namespace JT808.Gateway.Kafka +{ + public sealed class JT808MsgReplyLoggingConsumer : IJT808MsgReplyLoggingConsumer + { + private bool disposed = false; + public CancellationTokenSource Cts { get; private set; } = new CancellationTokenSource(); + + private readonly IConsumer consumer; + + private readonly ILogger logger; + + public string TopicName { get; } + + public JT808MsgReplyLoggingConsumer( + IOptions consumerConfigAccessor, + ILoggerFactory loggerFactory) + { + consumer = new ConsumerBuilder(consumerConfigAccessor.Value).Build(); + TopicName = consumerConfigAccessor.Value.TopicName; + logger = loggerFactory.CreateLogger(); + } + + public void OnMessage(Action<(string TerminalNo, byte[] Data)> callback) + { + Task.Run(() => + { + while (!Cts.IsCancellationRequested) + { + if (disposed) return; + try + { + //如果不指定分区,根据kafka的机制会从多个分区中拉取数据 + //如果指定分区,根据kafka的机制会从相应的分区中拉取数据 + var data = consumer.Consume(Cts.Token); + if (logger.IsEnabled(LogLevel.Debug)) + { + logger.LogDebug($"Topic: {data.Topic} Key: {data.Message.Key} Partition: {data.Partition} Offset: {data.Offset} TopicPartitionOffset:{data.TopicPartitionOffset}"); + } + callback((data.Message.Key, data.Message.Value)); + } + catch (ConsumeException ex) + { + logger.LogError(ex, TopicName); + } + catch (OperationCanceledException ex) + { + logger.LogError(ex, TopicName); + } + catch (Exception ex) + { + logger.LogError(ex, TopicName); + } + } + }, Cts.Token); + } + + public void Subscribe() + { + consumer.Subscribe(TopicName); + } + + public void Unsubscribe() + { + if (disposed) return; + consumer.Unsubscribe(); + Cts.Cancel(); + } + + private void Dispose(bool disposing) + { + if (disposed) return; + if (disposing) + { + consumer.Close(); + consumer.Dispose(); + Cts.Dispose(); + } + disposed = true; + } + ~JT808MsgReplyLoggingConsumer() + { + Dispose(false); + } + public void Dispose() + { + //必须为true + Dispose(true); + //通知垃圾回收机制不再调用终结器(析构器) + GC.SuppressFinalize(this); + } + } +} diff --git a/src/JT808.Gateway.Kafka/JT808MsgReplyLoggingProducer.cs b/src/JT808.Gateway.Kafka/JT808MsgReplyLoggingProducer.cs new file mode 100644 index 0000000..09f830a --- /dev/null +++ b/src/JT808.Gateway.Kafka/JT808MsgReplyLoggingProducer.cs @@ -0,0 +1,56 @@ +using Confluent.Kafka; +using JT808.Gateway.Configs.Kafka; +using JT808.Gateway.Abstractions; +using Microsoft.Extensions.Options; +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading.Tasks; + +namespace JT808.Gateway.Kafka +{ + public sealed class JT808MsgReplyLoggingProducer : IJT808MsgReplyLoggingProducer + { + private bool disposed = false; + public string TopicName { get;} + + private IProducer producer; + public JT808MsgReplyLoggingProducer( + IOptions producerConfigAccessor) + { + producer = new ProducerBuilder(producerConfigAccessor.Value).Build(); + TopicName = producerConfigAccessor.Value.TopicName; + } + + public async ValueTask ProduceAsync(string terminalNo, byte[] data) + { + if (disposed) return; + await producer.ProduceAsync(TopicName, new Message + { + Key = terminalNo, + Value = data + }); + } + + private void Dispose(bool disposing) + { + if (disposed) return; + if (disposing) + { + producer.Dispose(); + } + disposed = true; + } + ~JT808MsgReplyLoggingProducer() + { + Dispose(false); + } + public void Dispose() + { + //必须为true + Dispose(true); + //通知垃圾回收机制不再调用终结器(析构器) + GC.SuppressFinalize(this); + } + } +} diff --git a/src/JT808.Gateway.Kafka/JT808ServerKafkaExtensions.cs b/src/JT808.Gateway.Kafka/JT808ServerKafkaExtensions.cs index 3d9d9b0..3c9d4cf 100644 --- a/src/JT808.Gateway.Kafka/JT808ServerKafkaExtensions.cs +++ b/src/JT808.Gateway.Kafka/JT808ServerKafkaExtensions.cs @@ -44,5 +44,17 @@ namespace JT808.Gateway.Kafka jT808GatewayBuilder.JT808Builder.Services.Replace(new ServiceDescriptor(typeof(IJT808SessionProducer), typeof(JT808SessionProducer), ServiceLifetime.Singleton)); return jT808GatewayBuilder; } + /// + /// + /// + /// + /// GetSection("JT808MsgReplyLoggingProducerConfig") + /// + public static IJT808GatewayBuilder AddServerKafkaMsgReplyLoggingProducer(this IJT808GatewayBuilder jT808GatewayBuilder, IConfiguration configuration) + { + jT808GatewayBuilder.JT808Builder.Services.Configure(configuration.GetSection("JT808MsgReplyLoggingProducerConfig")); + jT808GatewayBuilder.JT808Builder.Services.Replace(new ServiceDescriptor(typeof(IJT808MsgReplyLoggingProducer), typeof(JT808MsgReplyLoggingProducer), ServiceLifetime.Singleton)); + return jT808GatewayBuilder; + } } } \ No newline at end of file diff --git a/src/JT808.Gateway.Kafka/JT808SessionConsumer.cs b/src/JT808.Gateway.Kafka/JT808SessionConsumer.cs index 92a4424..97d56dd 100644 --- a/src/JT808.Gateway.Kafka/JT808SessionConsumer.cs +++ b/src/JT808.Gateway.Kafka/JT808SessionConsumer.cs @@ -28,7 +28,7 @@ namespace JT808.Gateway.Kafka { consumer = new ConsumerBuilder(consumerConfigAccessor.Value).Build(); TopicName = consumerConfigAccessor.Value.TopicName; - logger = loggerFactory.CreateLogger("JT808SessionConsumer"); + logger = loggerFactory.CreateLogger(); } public void OnMessage(Action<(string Notice, string TerminalNo)> callback) diff --git a/src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808MsgDownReplyLoggingHostedService.cs b/src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808MsgDownReplyLoggingHostedService.cs new file mode 100644 index 0000000..0aa2ed9 --- /dev/null +++ b/src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808MsgDownReplyLoggingHostedService.cs @@ -0,0 +1,36 @@ +using System.Threading.Tasks; +using Microsoft.Extensions.Hosting; +using System.Threading; +using JT808.Gateway.Abstractions; + +namespace JT808.Gateway.MsgLogging +{ + public class JT808MsgDownReplyLoggingHostedService : IHostedService + { + private readonly IJT808MsgReplyLoggingConsumer jT808MsgReplyLoggingConsumer; + private readonly IJT808MsgLogging jT808MsgLogging; + public JT808MsgDownReplyLoggingHostedService( + IJT808MsgLogging jT808MsgLogging, + IJT808MsgReplyLoggingConsumer jT808MsgReplyLoggingConsumer) + { + this.jT808MsgReplyLoggingConsumer = jT808MsgReplyLoggingConsumer; + this.jT808MsgLogging = jT808MsgLogging; + } + + public Task StartAsync(CancellationToken cancellationToken) + { + jT808MsgReplyLoggingConsumer.Subscribe(); + jT808MsgReplyLoggingConsumer.OnMessage(item=> + { + jT808MsgLogging.Processor(item, JT808MsgLoggingType.down); + }); + return Task.CompletedTask; + } + + public Task StopAsync(CancellationToken cancellationToken) + { + jT808MsgReplyLoggingConsumer.Unsubscribe(); + return Task.CompletedTask; + } + } +} diff --git a/src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808MsgLoggingExtensions.cs b/src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808MsgLoggingExtensions.cs index 6b16d52..a5068a7 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808MsgLoggingExtensions.cs +++ b/src/JT808.Gateway.Services/JT808.Gateway.MsgLogging/JT808MsgLoggingExtensions.cs @@ -13,15 +13,16 @@ namespace JT808.Gateway.MsgLogging { jT808ClientBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808MsgLogging),typeof(TJT808MsgLogging)); jT808ClientBuilder.JT808Builder.Services.AddHostedService(); + jT808ClientBuilder.JT808Builder.Services.AddHostedService(); jT808ClientBuilder.JT808Builder.Services.AddHostedService(); return jT808ClientBuilder; } - public static IJT808GatewayBuilder AddMsgLogging(this IJT808GatewayBuilder jT808NormalGatewayBuilder) + public static IJT808GatewayBuilder AddMsgLogging(this IJT808GatewayBuilder jT808GatewayBuilder) where TJT808MsgLogging : IJT808MsgLogging { - jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808MsgLogging), typeof(TJT808MsgLogging)); - return jT808NormalGatewayBuilder; + jT808GatewayBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808MsgLogging), typeof(TJT808MsgLogging)); + return jT808GatewayBuilder; } } } diff --git a/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageExtensions.cs b/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageExtensions.cs index 77b6f16..bc44020 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageExtensions.cs +++ b/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageExtensions.cs @@ -9,29 +9,17 @@ namespace JT808.Gateway.ReplyMessage { public static class JT808ReplyMessageExtensions { - ///// - ///// 消息应答服务(不同的消费者实例) - ///// - ///// - ///// - //public static IJT808ClientBuilder AddReplyMessage(this IJT808ClientBuilder jT808ClientBuilder) - //{ - // jT808ClientBuilder.JT808Builder.Services.AddSingleton(); - // jT808ClientBuilder.JT808Builder.Services.AddHostedService(); - // return jT808ClientBuilder; - //} - ///// - ///// 消息应答服务(不同的消费者实例) - ///// - ///// 自定义消息回复服务 - ///// - ///// - //public static IJT808ClientBuilder AddReplyMessage(this IJT808ClientBuilder jT808ClientBuilder) - // where TReplyMessageHandler : JT808QueueReplyMessageHandler - //{ - // jT808ClientBuilder.JT808Builder.Services.AddSingleton(); - // jT808ClientBuilder.JT808Builder.Services.AddHostedService(); - // return jT808ClientBuilder; - //} + /// + /// 消息应答服务(不同的消费者实例) + /// + /// + /// + public static IJT808ClientBuilder AddReplyMessage(this IJT808ClientBuilder jT808ClientBuilder) + where TJT808ReplyMessageHandler : IJT808ReplyMessageHandler + { + jT808ClientBuilder.JT808Builder.Services.AddSingleton(new ServiceDescriptor(typeof(IJT808ReplyMessageHandler),typeof(TJT808ReplyMessageHandler), ServiceLifetime.Singleton)); + jT808ClientBuilder.JT808Builder.Services.AddHostedService(); + return jT808ClientBuilder; + } } } diff --git a/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageHostedService.cs b/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageHostedService.cs index cf5be45..b2180d9 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageHostedService.cs +++ b/src/JT808.Gateway.Services/JT808.Gateway.ReplyMessage/JT808ReplyMessageHostedService.cs @@ -5,30 +5,32 @@ using JT808.Gateway.Abstractions; namespace JT808.Gateway.ReplyMessage { - //public class JT808ReplyMessageHostedService : IHostedService - //{ - // //private readonly IJT808MsgConsumer jT808MsgConsumer; - // //private readonly JT808QueueReplyMessageHandler jT808ReplyMessageHandler; + public class JT808ReplyMessageHostedService : IHostedService + { + private IJT808MsgConsumer jT808MsgConsumer; + private IJT808ReplyMessageHandler jT808ReplyMessageHandler; - // //public JT808ReplyMessageHostedService( - // // JT808QueueReplyMessageHandler jT808ReplyMessageHandler, - // // IJT808MsgConsumer jT808MsgConsumer) - // //{ - // // this.jT808MsgConsumer = jT808MsgConsumer; - // // this.jT808ReplyMessageHandler = jT808ReplyMessageHandler; - // //} + public JT808ReplyMessageHostedService( + IJT808ReplyMessageHandler jT808ReplyMessageHandler, + IJT808MsgConsumer jT808MsgConsumer) + { + this.jT808MsgConsumer = jT808MsgConsumer; + this.jT808ReplyMessageHandler = jT808ReplyMessageHandler; + } - // //public Task StartAsync(CancellationToken cancellationToken) - // //{ - // // jT808MsgConsumer.Subscribe(); - // // jT808MsgConsumer.OnMessage(jT808ReplyMessageHandler.Processor); - // // return Task.CompletedTask; - // //} + public Task StartAsync(CancellationToken cancellationToken) + { + jT808MsgConsumer.Subscribe(); + jT808MsgConsumer.OnMessage((Message)=> { + jT808ReplyMessageHandler.Processor(Message.TerminalNo, Message.Data); + }); + return Task.CompletedTask; + } - // //public Task StopAsync(CancellationToken cancellationToken) - // //{ - // // jT808MsgConsumer.Unsubscribe(); - // // return Task.CompletedTask; - // //} - //} + public Task StopAsync(CancellationToken cancellationToken) + { + jT808MsgConsumer.Unsubscribe(); + return Task.CompletedTask; + } + } } diff --git a/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeExtensions.cs b/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeExtensions.cs index 9d8293b..d59c22b 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeExtensions.cs +++ b/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeExtensions.cs @@ -38,13 +38,13 @@ namespace JT808.Gateway.SessionNotice /// /// 会话通知服务(不同的消费者实例) /// - /// + /// /// - public static IJT808GatewayBuilder AddSessionNotice(this IJT808GatewayBuilder jT808NormalGatewayBuilder) + public static IJT808GatewayBuilder AddSessionNotice(this IJT808GatewayBuilder jT808GatewayBuilder) { - jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton(); - jT808NormalGatewayBuilder.JT808Builder.Services.AddHostedService(); - return jT808NormalGatewayBuilder; + jT808GatewayBuilder.JT808Builder.Services.AddSingleton(); + jT808GatewayBuilder.JT808Builder.Services.AddHostedService(); + return jT808GatewayBuilder; } /// diff --git a/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeService.cs b/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeService.cs index 6ce04bd..f76aee9 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeService.cs +++ b/src/JT808.Gateway.Services/JT808.Gateway.SessionNotice/JT808SessionNoticeService.cs @@ -11,7 +11,7 @@ namespace JT808.Gateway.SessionNotice protected ILogger logger { get; } public JT808SessionNoticeService(ILoggerFactory loggerFactory) { - logger = loggerFactory.CreateLogger("JT808SessionNoticeService"); + logger = loggerFactory.CreateLogger(); } public virtual void Processor((string Notice, string TerminalNo) parameter) { diff --git a/src/JT808.Gateway.Services/JT808.Gateway.Traffic/JT808TrafficServiceExtensions.cs b/src/JT808.Gateway.Services/JT808.Gateway.Traffic/JT808TrafficServiceExtensions.cs index 16e89ad..1c39252 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.Traffic/JT808TrafficServiceExtensions.cs +++ b/src/JT808.Gateway.Services/JT808.Gateway.Traffic/JT808TrafficServiceExtensions.cs @@ -36,13 +36,13 @@ namespace JT808.Gateway.Traffic /// /// 消息流量统计服务(不同的消费者实例) /// - /// + /// /// - public static IJT808GatewayBuilder AddTraffic(this IJT808GatewayBuilder jT808NormalGatewayBuilder) + public static IJT808GatewayBuilder AddTraffic(this IJT808GatewayBuilder jT808GatewayBuilder) where TIJT808Traffic : IJT808Traffic { - jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808Traffic), typeof(TIJT808Traffic)); - return jT808NormalGatewayBuilder; + jT808GatewayBuilder.JT808Builder.Services.AddSingleton(typeof(IJT808Traffic), typeof(TIJT808Traffic)); + return jT808GatewayBuilder; } diff --git a/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808.Gateway.Transmit.csproj b/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808.Gateway.Transmit.csproj index 64ba4aa..03a80f5 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808.Gateway.Transmit.csproj +++ b/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808.Gateway.Transmit.csproj @@ -21,9 +21,6 @@ 基于JT808实现的数据转发服务 LICENSE - - - diff --git a/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitExtensions.cs b/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitExtensions.cs index f4d7cce..bd47827 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitExtensions.cs +++ b/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitExtensions.cs @@ -28,14 +28,14 @@ namespace JT808.Gateway.Transmit /// /// 转发服务(不同的消费者实例) /// - /// + /// /// /// - public static IJT808GatewayBuilder AddTransmit(this IJT808GatewayBuilder jT808NormalGatewayBuilder, IConfiguration configuration) + public static IJT808GatewayBuilder AddTransmit(this IJT808GatewayBuilder jT808GatewayBuilder, IConfiguration configuration) { - jT808NormalGatewayBuilder.JT808Builder.Services.Configure(configuration.GetSection("RemoteServerOptions")); - jT808NormalGatewayBuilder.JT808Builder.Services.AddSingleton(); - return jT808NormalGatewayBuilder; + jT808GatewayBuilder.JT808Builder.Services.Configure(configuration.GetSection("RemoteServerOptions")); + jT808GatewayBuilder.JT808Builder.Services.AddSingleton(); + return jT808GatewayBuilder; } } } diff --git a/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitService.cs b/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitService.cs index 228ede2..4ee3b13 100644 --- a/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitService.cs +++ b/src/JT808.Gateway.Services/JT808.Gateway.Transmit/JT808TransmitService.cs @@ -22,7 +22,7 @@ namespace JT808.Gateway.Transmit public JT808TransmitService(ILoggerFactory loggerFactory, IOptionsMonitor optionsMonitor) { - logger = loggerFactory.CreateLogger("JT808TransmitService"); + logger = loggerFactory.CreateLogger(); this.optionsMonitor = optionsMonitor; InitialDispatcherClient(); } diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808CustomMessageHandlerImpl.cs b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808CustomMessageHandlerImpl.cs index 3fd717b..b22f357 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808CustomMessageHandlerImpl.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808CustomMessageHandlerImpl.cs @@ -1,7 +1,6 @@ using JT808.Gateway.Abstractions; using JT808.Gateway.Abstractions.Configurations; using JT808.Gateway.MsgLogging; -using JT808.Gateway.Traffic; using JT808.Gateway.Transmit; using JT808.Protocol; using Microsoft.Extensions.Logging; @@ -15,7 +14,6 @@ namespace JT808.Gateway.NormalHosting.Impl public class JT808CustomMessageHandlerImpl : JT808MessageHandler { private readonly ILogger logger; - //private readonly IJT808Traffic jT808Traffic; //private readonly JT808TransmitService jT808TransmitService; private readonly IJT808MsgLogging jT808MsgLogging; private readonly IJT808MsgReplyProducer MsgReplyProducer; @@ -34,7 +32,6 @@ namespace JT808.Gateway.NormalHosting.Impl { MsgReplyProducer = msgReplyProducer; //this.jT808TransmitService = jT808TransmitService; - //this.jT808Traffic = jT808Traffic; this.jT808MsgLogging = jT808MsgLogging; logger = loggerFactory.CreateLogger(); //添加自定义消息 diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808MsgLogging.cs b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808MsgLogging.cs index 95f2a87..79f5c91 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808MsgLogging.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Impl/JT808MsgLogging.cs @@ -12,7 +12,7 @@ namespace JT808.Gateway.NormalHosting.Impl private readonly ILogger Logger; public JT808MsgLogging(ILoggerFactory loggerFactory) { - Logger = loggerFactory.CreateLogger("JT808MsgLogging"); + Logger = loggerFactory.CreateLogger(); } public void Processor((string TerminalNo, byte[] Data) parameter, JT808MsgLoggingType jT808MsgLoggingType) { diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj index d338923..f2d3c72 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/JT808.Gateway.NormalHosting.csproj @@ -21,7 +21,6 @@ - diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/TrafficJob.cs b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/TrafficJob.cs deleted file mode 100644 index 084cd87..0000000 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/TrafficJob.cs +++ /dev/null @@ -1,48 +0,0 @@ -using JT808.Gateway.Traffic; -using JT808.Protocol.Enums; -using JT808.Protocol.Extensions; -using JT808.Protocol.MessageBody; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Logging; -using System; -using System.Collections.Generic; -using System.Text; -using System.Threading; -using System.Threading.Tasks; - -namespace JT808.Gateway.NormalHosting.Jobs -{ - public class TrafficJob : IHostedService - { - private readonly IJT808Traffic jT808Traffic; - private readonly ILogger Logger; - public TrafficJob( - ILoggerFactory loggerFactory, - IJT808Traffic jT808Traffic) - { - Logger = loggerFactory.CreateLogger("TrafficJob"); - this.jT808Traffic = jT808Traffic; - } - - public Task StartAsync(CancellationToken cancellationToken) - { - Task.Run(async () => - { - while (!cancellationToken.IsCancellationRequested) - { - await Task.Delay(2 * 1000); - foreach (var item in jT808Traffic.GetAll()) - { - Logger.LogDebug($"{item.Item1}-{item.Item2}"); - } - } - }, cancellationToken); - return Task.CompletedTask; - } - - public Task StopAsync(CancellationToken cancellationToken) - { - return Task.CompletedTask; - } - } -} diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/UpJob.cs b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/UpJob.cs index d20b5fb..af3fcd7 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/UpJob.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Jobs/UpJob.cs @@ -20,7 +20,7 @@ namespace JT808.Gateway.NormalHosting.Jobs ILoggerFactory loggerFactory, IJT808TcpClientFactory jT808TcpClientFactory) { - Logger = loggerFactory.CreateLogger("UpJob"); + Logger = loggerFactory.CreateLogger(); this.jT808TcpClientFactory = jT808TcpClientFactory; } diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs index 74d2d03..08e07b0 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.NormalHosting/Program.cs @@ -9,7 +9,6 @@ using NLog.Extensions.Logging; using JT808.Gateway.NormalHosting.Impl; using JT808.Gateway.MsgLogging; using JT808.Gateway.Transmit; -using JT808.Gateway.Traffic; using JT808.Gateway.NormalHosting.Services; using JT808.Gateway.Abstractions; using JT808.Gateway.SessionNotice; @@ -54,7 +53,6 @@ namespace JT808.Gateway.NormalHosting .AddMessageHandler() .AddMsgReplyConsumer() .AddMsgLogging() - //.AddTraffic() //.AddSessionNotice() //.AddTransmit(hostContext.Configuration) .AddTcp() diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/JT808.Gateway.QueueHosting.csproj b/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/JT808.Gateway.QueueHosting.csproj index ab48acf..0852ba0 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/JT808.Gateway.QueueHosting.csproj +++ b/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/JT808.Gateway.QueueHosting.csproj @@ -19,11 +19,9 @@ - - diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/UpJob.cs b/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/UpJob.cs index a31a924..01ad297 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/UpJob.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Jobs/UpJob.cs @@ -20,7 +20,7 @@ namespace JT808.Gateway.QueueHosting.Jobs ILoggerFactory loggerFactory, IJT808TcpClientFactory jT808TcpClientFactory) { - Logger = loggerFactory.CreateLogger("UpJob"); + Logger = loggerFactory.CreateLogger(); this.jT808TcpClientFactory = jT808TcpClientFactory; } diff --git a/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Program.cs b/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Program.cs index da7c251..fa9e83e 100644 --- a/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Program.cs +++ b/src/JT808.Gateway.Tests/JT808.Gateway.QueueHosting/Program.cs @@ -9,7 +9,6 @@ using NLog.Extensions.Logging; using JT808.Gateway.MsgLogging; using JT808.Gateway.ReplyMessage; using JT808.Gateway.Transmit; -using JT808.Gateway.Traffic; using JT808.Gateway.Abstractions; using JT808.Gateway.SessionNotice; using JT808.Gateway.Client; diff --git a/src/JT808.Gateway.sln b/src/JT808.Gateway.sln index 4a366d7..3a9d550 100644 --- a/src/JT808.Gateway.sln +++ b/src/JT808.Gateway.sln @@ -11,8 +11,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.Kafka", "JT80 EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Services", "Services", "{3EF8490D-C993-49D8-8A3D-493B7F259D70}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.MsgIdHandler", "JT808.Gateway.Services\JT808.Gateway.MsgIdHandler\JT808.Gateway.MsgIdHandler.csproj", "{D62E3054-6924-4F1A-9BEF-E52B191F16B6}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.MsgLogging", "JT808.Gateway.Services\JT808.Gateway.MsgLogging\JT808.Gateway.MsgLogging.csproj", "{A242A839-4F00-4434-A7E8-7E3BEBA5B75C}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.SessionNotice", "JT808.Gateway.Services\JT808.Gateway.SessionNotice\JT808.Gateway.SessionNotice.csproj", "{1CB84599-5F56-4461-A451-DF16E3854AB9}" @@ -35,8 +33,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.CleintBenchma EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.ServerBenchmark", "JT808.Gateway.Benchmark\JT808.Gateway.ServerBenchmark\JT808.Gateway.ServerBenchmark.csproj", "{AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.Traffic", "JT808.Gateway.Services\JT808.Gateway.Traffic\JT808.Gateway.Traffic.csproj", "{E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE}" -EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.WebApiClientTool", "JT808.Gateway.WebApiClientTool\JT808.Gateway.WebApiClientTool.csproj", "{479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.ReplyMessage", "JT808.Gateway.Services\JT808.Gateway.ReplyMessage\JT808.Gateway.ReplyMessage.csproj", "{886D0A3F-C974-442B-9820-F1C4C04EAAB6}" @@ -59,10 +55,6 @@ Global {274C048E-A8E3-4422-A578-A10A97DF36F2}.Debug|Any CPU.Build.0 = Debug|Any CPU {274C048E-A8E3-4422-A578-A10A97DF36F2}.Release|Any CPU.ActiveCfg = Release|Any CPU {274C048E-A8E3-4422-A578-A10A97DF36F2}.Release|Any CPU.Build.0 = Release|Any CPU - {D62E3054-6924-4F1A-9BEF-E52B191F16B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D62E3054-6924-4F1A-9BEF-E52B191F16B6}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D62E3054-6924-4F1A-9BEF-E52B191F16B6}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D62E3054-6924-4F1A-9BEF-E52B191F16B6}.Release|Any CPU.Build.0 = Release|Any CPU {A242A839-4F00-4434-A7E8-7E3BEBA5B75C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A242A839-4F00-4434-A7E8-7E3BEBA5B75C}.Debug|Any CPU.Build.0 = Debug|Any CPU {A242A839-4F00-4434-A7E8-7E3BEBA5B75C}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -99,10 +91,6 @@ Global {AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}.Debug|Any CPU.Build.0 = Debug|Any CPU {AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}.Release|Any CPU.ActiveCfg = Release|Any CPU {AF0C529A-D3CA-4FE4-93B4-735D0934EBEF}.Release|Any CPU.Build.0 = Release|Any CPU - {E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE}.Release|Any CPU.Build.0 = Release|Any CPU {479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}.Debug|Any CPU.Build.0 = Debug|Any CPU {479DFD02-4777-4DC2-9E2E-8EA33BFB36C9}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -116,7 +104,6 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {D62E3054-6924-4F1A-9BEF-E52B191F16B6} = {3EF8490D-C993-49D8-8A3D-493B7F259D70} {A242A839-4F00-4434-A7E8-7E3BEBA5B75C} = {3EF8490D-C993-49D8-8A3D-493B7F259D70} {1CB84599-5F56-4461-A451-DF16E3854AB9} = {3EF8490D-C993-49D8-8A3D-493B7F259D70} {598E445A-AF2E-42F0-98F4-18EC22E473FC} = {3EF8490D-C993-49D8-8A3D-493B7F259D70} @@ -125,7 +112,6 @@ Global {52D895BD-C60B-42D8-9229-C85927546FDA} = {7CBAACEE-19BF-499A-8C41-36A1324D45E9} {E34C6B7D-A48B-4871-895C-07AC12F959D3} = {6FAEC008-93CB-4730-8C58-D31FFD342C4F} {AF0C529A-D3CA-4FE4-93B4-735D0934EBEF} = {6FAEC008-93CB-4730-8C58-D31FFD342C4F} - {E5A0BFB6-4345-4592-A2B1-E3CB1FA423AE} = {3EF8490D-C993-49D8-8A3D-493B7F259D70} {886D0A3F-C974-442B-9820-F1C4C04EAAB6} = {3EF8490D-C993-49D8-8A3D-493B7F259D70} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution diff --git a/src/JT808.Gateway/JT808TcpServer.cs b/src/JT808.Gateway/JT808TcpServer.cs index 2d5c88b..1b85faf 100644 --- a/src/JT808.Gateway/JT808TcpServer.cs +++ b/src/JT808.Gateway/JT808TcpServer.cs @@ -48,7 +48,7 @@ namespace JT808.Gateway { MessageHandler = messageHandler; SessionManager = jT808SessionManager; - Logger = loggerFactory.CreateLogger("JT808TcpServer"); + Logger = loggerFactory.CreateLogger(); Serializer = jT808Config.GetSerializer(); Configuration = jT808ConfigurationAccessor.Value; InitServer(); diff --git a/src/JT808.Gateway/Services/JT808TcpReceiveTimeoutHostedService.cs b/src/JT808.Gateway/Services/JT808TcpReceiveTimeoutHostedService.cs index 40dc321..86a4124 100644 --- a/src/JT808.Gateway/Services/JT808TcpReceiveTimeoutHostedService.cs +++ b/src/JT808.Gateway/Services/JT808TcpReceiveTimeoutHostedService.cs @@ -25,7 +25,7 @@ namespace JT808.Gateway.Services ) { SessionManager = jT808SessionManager; - Logger = loggerFactory.CreateLogger("JT808TcpReceiveTimeout"); + Logger = loggerFactory.CreateLogger(); Configuration = jT808ConfigurationAccessor.Value; } diff --git a/src/JT808.Gateway/Services/JT808UdpReceiveTimeoutHostedService.cs b/src/JT808.Gateway/Services/JT808UdpReceiveTimeoutHostedService.cs index 3e79fc3..3646262 100644 --- a/src/JT808.Gateway/Services/JT808UdpReceiveTimeoutHostedService.cs +++ b/src/JT808.Gateway/Services/JT808UdpReceiveTimeoutHostedService.cs @@ -25,7 +25,7 @@ namespace JT808.Gateway.Services ) { SessionManager = jT808SessionManager; - Logger = loggerFactory.CreateLogger("JT808UdpReceiveTimeout"); + Logger = loggerFactory.CreateLogger(); Configuration = jT808ConfigurationAccessor.Value; }