@@ -109,6 +109,8 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网 | |||
### Pipeline | |||
#### 使用网关集成方式 | |||
1.打开/simples/JT808.Simples.sln项目进行还原编译生成 | |||
2.进入JT808.Gateway.SimpleServer项目下的Debug目录运行服务端 | |||
@@ -118,6 +120,21 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网 | |||
如图所示: | |||
 | |||
#### 使用队列方式 | |||
1.打开/simples/JT808.Simples.sln项目进行还原编译生成 | |||
2.JT808.Gateway.SimpleQueueServer项目下的Debug目录运行服务端 | |||
3.JT808.Gateway.SimpleQueueService项目下的Debug目录运行消息处理服务 | |||
4.进入JT808.Gateway.SimpleClient项目下的Debug目录运行客户端 | |||
> 注意:需要安装kafka和zookeeper | |||
如图所示: | |||
 | |||
### DotNetty | |||
1.打开/simples/JT808.Simples.sln项目进行还原编译生成 | |||
@@ -6,8 +6,8 @@ | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="JT808.Gateway.Abstractions" Version="1.0.0-preview7" /> | |||
<PackageReference Include="JT808.Gateway.Client" Version="1.0.0-preview7" /> | |||
<PackageReference Include="JT808.Gateway.Abstractions" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.Client" Version="1.0.0-preview8" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.1" /> | |||
@@ -0,0 +1,23 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<OutputType>Exe</OutputType> | |||
<TargetFramework>netcoreapp3.1</TargetFramework> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="JT808.Gateway" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.Kafka" Version="1.0.0-preview8" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Update="appsettings.json"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</None> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,45 @@ | |||
using JT808.Protocol; | |||
using Microsoft.Extensions.Configuration; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using Microsoft.Extensions.Hosting; | |||
using Microsoft.Extensions.Logging; | |||
using System; | |||
using System.Threading.Tasks; | |||
using JT808.Gateway.Kafka; | |||
namespace JT808.Gateway.SimpleQueueServer | |||
{ | |||
class Program | |||
{ | |||
static async Task Main(string[] args) | |||
{ | |||
var serverHostBuilder = new HostBuilder() | |||
.ConfigureAppConfiguration((hostingContext, config) => | |||
{ | |||
config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); | |||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); | |||
}) | |||
.ConfigureLogging((context, logging) => | |||
{ | |||
logging.AddConsole(); | |||
logging.SetMinimumLevel(LogLevel.Trace); | |||
}) | |||
.ConfigureServices((hostContext, services) => | |||
{ | |||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | |||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | |||
services.AddJT808Configure() | |||
.AddQueueGateway(hostContext.Configuration) | |||
.AddServerKafkaMsgProducer(hostContext.Configuration) | |||
.AddServerKafkaMsgReplyConsumer(hostContext.Configuration) | |||
.AddServerKafkaSessionProducer(hostContext.Configuration) | |||
.AddTcp() | |||
.AddUdp() | |||
.AddGrpc() | |||
.Builder(); | |||
}); | |||
await serverHostBuilder.RunConsoleAsync(); | |||
} | |||
} | |||
} |
@@ -0,0 +1,37 @@ | |||
using JT808.Gateway.Abstractions; | |||
using JT808.Protocol; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT808.Gateway.SimpleQueueService.Impl | |||
{ | |||
public class JT808QueueReplyMessageHandlerImpl : JT808QueueReplyMessageHandler | |||
{ | |||
public JT808QueueReplyMessageHandlerImpl(IJT808Config jT808Config, IJT808MsgReplyProducer jT808MsgReplyProducer) : base(jT808Config, jT808MsgReplyProducer) | |||
{ | |||
//添加自定义消息 | |||
HandlerDict.Add(0x9999, Msg0x9999); | |||
} | |||
/// <summary> | |||
/// 重写消息 | |||
/// </summary> | |||
/// <param name="request"></param> | |||
/// <returns></returns> | |||
public override byte[] Msg0x0001(JT808HeaderPackage request) | |||
{ | |||
return base.Msg0x0001(request); | |||
} | |||
/// <summary> | |||
/// 自定义消息 | |||
/// </summary> | |||
/// <param name="request"></param> | |||
/// <returns></returns> | |||
public byte[] Msg0x9999(JT808HeaderPackage request) | |||
{ | |||
return default; | |||
} | |||
} | |||
} |
@@ -0,0 +1,20 @@ | |||
using JT808.Gateway.SessionNotice; | |||
using Microsoft.Extensions.Logging; | |||
using System; | |||
using System.Collections.Generic; | |||
using System.Text; | |||
namespace JT808.Gateway.SimpleQueueService.Impl | |||
{ | |||
public class JT808SessionNoticeServiceImpl : JT808SessionNoticeService | |||
{ | |||
public JT808SessionNoticeServiceImpl(ILoggerFactory loggerFactory) : base(loggerFactory) | |||
{ | |||
} | |||
public override void Processor((string Notice, string TerminalNo) parameter) | |||
{ | |||
base.Processor(parameter); | |||
} | |||
} | |||
} |
@@ -0,0 +1,29 @@ | |||
<Project Sdk="Microsoft.NET.Sdk"> | |||
<PropertyGroup> | |||
<OutputType>Exe</OutputType> | |||
<TargetFramework>netcoreapp3.1</TargetFramework> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="JT808.Gateway" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.Kafka" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.MsgIdHandler" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.MsgLogging" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.ReplyMessage" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.SessionNotice" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.Traffic" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.Transmit" Version="1.0.0-preview8" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.1" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Update="appsettings.json"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</None> | |||
</ItemGroup> | |||
</Project> |
@@ -0,0 +1,43 @@ | |||
using JT808.Protocol; | |||
using JT808.Gateway.Kafka; | |||
using JT808.Gateway.ReplyMessage; | |||
using JT808.Gateway.SessionNotice; | |||
using Microsoft.Extensions.Configuration; | |||
using Microsoft.Extensions.DependencyInjection; | |||
using Microsoft.Extensions.Hosting; | |||
using Microsoft.Extensions.Logging; | |||
using System; | |||
using System.Threading.Tasks; | |||
using JT808.Gateway.SimpleQueueService.Impl; | |||
namespace JT808.Gateway.SimpleQueueService | |||
{ | |||
class Program | |||
{ | |||
static async Task Main(string[] args) | |||
{ | |||
var hostBuilder = new HostBuilder() | |||
.ConfigureAppConfiguration((hostContext, config) => { | |||
config.SetBasePath(AppDomain.CurrentDomain.BaseDirectory); | |||
config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true); | |||
}) | |||
.ConfigureLogging((hostContext, configLogging) => { | |||
configLogging.AddConsole(); | |||
configLogging.SetMinimumLevel(LogLevel.Trace); | |||
}) | |||
.ConfigureServices((hostContext, services) => { | |||
services.AddSingleton<ILoggerFactory, LoggerFactory>(); | |||
services.AddSingleton(typeof(ILogger<>), typeof(Logger<>)); | |||
services.AddJT808Configure() | |||
.AddClientKafka() | |||
.AddMsgConsumer(hostContext.Configuration) | |||
.AddMsgReplyProducer(hostContext.Configuration) | |||
.AddSessionConsumer(hostContext.Configuration) | |||
.AddReplyMessage<JT808QueueReplyMessageHandlerImpl>() | |||
.AddSessionNotice<JT808SessionNoticeServiceImpl>(); | |||
}); | |||
await hostBuilder.RunConsoleAsync(); | |||
} | |||
} | |||
} |
@@ -46,7 +46,7 @@ namespace JT808.Gateway.SimpleServer.Impl | |||
//转发数据(可同步也可以使用队列进行异步) | |||
try | |||
{ | |||
jT808TransmitService.Send(parameter); | |||
jT808TransmitService.SendAsync(parameter); | |||
} | |||
catch (Exception ex) | |||
{ | |||
@@ -5,23 +5,17 @@ | |||
<TargetFramework>netcoreapp3.1</TargetFramework> | |||
</PropertyGroup> | |||
<ItemGroup> | |||
<PackageReference Include="JT808.Gateway" Version="1.0.0-preview7" /> | |||
<PackageReference Include="JT808.Gateway.MsgIdHandler" Version="1.0.0-preview7" /> | |||
<PackageReference Include="JT808.Gateway.MsgLogging" Version="1.0.0-preview7" /> | |||
<PackageReference Include="JT808.Gateway.ReplyMessage" Version="1.0.0-preview7" /> | |||
<PackageReference Include="JT808.Gateway.SessionNotice" Version="1.0.0-preview7" /> | |||
<PackageReference Include="JT808.Gateway.Traffic" Version="1.0.0-preview7" /> | |||
<PackageReference Include="JT808.Gateway.Transmit" Version="1.0.0-preview7" /> | |||
<PackageReference Include="JT808.Gateway" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.MsgIdHandler" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.MsgLogging" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.ReplyMessage" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.SessionNotice" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.Traffic" Version="1.0.0-preview8" /> | |||
<PackageReference Include="JT808.Gateway.Transmit" Version="1.0.0-preview8" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="3.1.1" /> | |||
<PackageReference Include="WebApiClient.Extensions.DependencyInjection" Version="2.0.3" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Update="appsettings.json"> | |||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> | |||
</None> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<None Update="appsettings.json"> | |||
@@ -29,4 +23,5 @@ | |||
</None> | |||
</ItemGroup> | |||
</Project> |
@@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.SimpleServer" | |||
EndProject | |||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.SimpleClient", "JT808.Gateway.SimpleClient\JT808.Gateway.SimpleClient.csproj", "{09AFAC3E-4E4D-4B51-962D-BF8489D8BEC6}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JT808.Gateway.SimpleQueueServer", "JT808.Gateway.SimpleQueueServer\JT808.Gateway.SimpleQueueServer.csproj", "{8594AC7F-18B4-439D-B58B-1CEFF0833A1A}" | |||
EndProject | |||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "JT808.Gateway.SimpleQueueService", "JT808.Gateway.SimpleQueueService\JT808.Gateway.SimpleQueueService.csproj", "{E2D1CFEF-417A-4C44-BC2E-E5A160602485}" | |||
EndProject | |||
Global | |||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
Debug|Any CPU = Debug|Any CPU | |||
@@ -35,6 +39,14 @@ Global | |||
{09AFAC3E-4E4D-4B51-962D-BF8489D8BEC6}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{09AFAC3E-4E4D-4B51-962D-BF8489D8BEC6}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{09AFAC3E-4E4D-4B51-962D-BF8489D8BEC6}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{8594AC7F-18B4-439D-B58B-1CEFF0833A1A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{8594AC7F-18B4-439D-B58B-1CEFF0833A1A}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{8594AC7F-18B4-439D-B58B-1CEFF0833A1A}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{8594AC7F-18B4-439D-B58B-1CEFF0833A1A}.Release|Any CPU.Build.0 = Release|Any CPU | |||
{E2D1CFEF-417A-4C44-BC2E-E5A160602485}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | |||
{E2D1CFEF-417A-4C44-BC2E-E5A160602485}.Debug|Any CPU.Build.0 = Debug|Any CPU | |||
{E2D1CFEF-417A-4C44-BC2E-E5A160602485}.Release|Any CPU.ActiveCfg = Release|Any CPU | |||
{E2D1CFEF-417A-4C44-BC2E-E5A160602485}.Release|Any CPU.Build.0 = Release|Any CPU | |||
EndGlobalSection | |||
GlobalSection(SolutionProperties) = preSolution | |||
HideSolutionNode = FALSE | |||
@@ -44,6 +56,8 @@ Global | |||
{CCE6AEFB-1AB0-4BD9-8EA2-8B4CDD097E88} = {2459FB59-8A33-49A4-ADBC-A0B12C5886A6} | |||
{98E1CDD0-4D4E-48FE-968E-260F0CD5F4D3} = {2459FB59-8A33-49A4-ADBC-A0B12C5886A6} | |||
{09AFAC3E-4E4D-4B51-962D-BF8489D8BEC6} = {2459FB59-8A33-49A4-ADBC-A0B12C5886A6} | |||
{8594AC7F-18B4-439D-B58B-1CEFF0833A1A} = {2459FB59-8A33-49A4-ADBC-A0B12C5886A6} | |||
{E2D1CFEF-417A-4C44-BC2E-E5A160602485} = {2459FB59-8A33-49A4-ADBC-A0B12C5886A6} | |||
EndGlobalSection | |||
GlobalSection(ExtensibilityGlobals) = postSolution | |||
SolutionGuid = {FC0FFCEA-E1EF-4C97-A1C5-F89418B6834B} | |||