Просмотр исходного кода

1.增加基于kafka的网关demo及简单服务

2.修改文档
tags/pipeline-1.0.0
smallchi(Koike) 5 лет назад
Родитель
Сommit
dcaaf08181
12 измененных файлов: 239 добавлений и 16 удалений
  1. +17
    -0
      README.md
  2. Двоичные данные
      doc/img/demo4.png
  3. +2
    -2
      simples/JT808.Gateway.SimpleClient/JT808.Gateway.SimpleClient.csproj
  4. +23
    -0
      simples/JT808.Gateway.SimpleQueueServer/JT808.Gateway.SimpleQueueServer.csproj
  5. +45
    -0
      simples/JT808.Gateway.SimpleQueueServer/Program.cs
  6. +37
    -0
      simples/JT808.Gateway.SimpleQueueService/Impl/JT808QueueReplyMessageHandlerImpl.cs
  7. +20
    -0
      simples/JT808.Gateway.SimpleQueueService/Impl/JT808SessionNoticeServiceImpl.cs
  8. +29
    -0
      simples/JT808.Gateway.SimpleQueueService/JT808.Gateway.SimpleQueueService.csproj
  9. +43
    -0
      simples/JT808.Gateway.SimpleQueueService/Program.cs
  10. +1
    -1
      simples/JT808.Gateway.SimpleServer/Impl/JT808NormalReplyMessageHandlerImpl.cs
  11. +8
    -13
      simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj
  12. +14
    -0
      simples/JT808.Simples.sln

+ 17
- 0
README.md Просмотреть файл

@@ -109,6 +109,8 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网


### Pipeline ### Pipeline


#### 使用网关集成方式

1.打开/simples/JT808.Simples.sln项目进行还原编译生成 1.打开/simples/JT808.Simples.sln项目进行还原编译生成


2.进入JT808.Gateway.SimpleServer项目下的Debug目录运行服务端 2.进入JT808.Gateway.SimpleServer项目下的Debug目录运行服务端
@@ -118,6 +120,21 @@ Pipeline分为两种方式使用,一种是使用队列的方式,一种是网
如图所示: 如图所示:
![demo3](https://github.com/SmallChi/JT808Gateway/blob/master/doc/img/demo3.png) ![demo3](https://github.com/SmallChi/JT808Gateway/blob/master/doc/img/demo3.png)


#### 使用队列方式

1.打开/simples/JT808.Simples.sln项目进行还原编译生成

2.JT808.Gateway.SimpleQueueServer项目下的Debug目录运行服务端

3.JT808.Gateway.SimpleQueueService项目下的Debug目录运行消息处理服务

4.进入JT808.Gateway.SimpleClient项目下的Debug目录运行客户端

> 注意:需要安装kafka和zookeeper

如图所示:
![demo4](https://github.com/SmallChi/JT808Gateway/blob/master/doc/img/demo4.png)

### DotNetty ### DotNetty


1.打开/simples/JT808.Simples.sln项目进行还原编译生成 1.打开/simples/JT808.Simples.sln项目进行还原编译生成


Двоичные данные
doc/img/demo4.png Просмотреть файл

До После
Ширина: 1881  |  Высота: 819  |  Размер: 116 KiB

+ 2
- 2
simples/JT808.Gateway.SimpleClient/JT808.Gateway.SimpleClient.csproj Просмотреть файл

@@ -6,8 +6,8 @@
</PropertyGroup> </PropertyGroup>


<ItemGroup> <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.FileExtensions" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" 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.Hosting" Version="3.1.1" />


+ 23
- 0
simples/JT808.Gateway.SimpleQueueServer/JT808.Gateway.SimpleQueueServer.csproj Просмотреть файл

@@ -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>

+ 45
- 0
simples/JT808.Gateway.SimpleQueueServer/Program.cs Просмотреть файл

@@ -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();
}
}
}

+ 37
- 0
simples/JT808.Gateway.SimpleQueueService/Impl/JT808QueueReplyMessageHandlerImpl.cs Просмотреть файл

@@ -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;
}
}
}

+ 20
- 0
simples/JT808.Gateway.SimpleQueueService/Impl/JT808SessionNoticeServiceImpl.cs Просмотреть файл

@@ -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);
}
}
}

+ 29
- 0
simples/JT808.Gateway.SimpleQueueService/JT808.Gateway.SimpleQueueService.csproj Просмотреть файл

@@ -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>

+ 43
- 0
simples/JT808.Gateway.SimpleQueueService/Program.cs Просмотреть файл

@@ -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();
}
}
}

+ 1
- 1
simples/JT808.Gateway.SimpleServer/Impl/JT808NormalReplyMessageHandlerImpl.cs Просмотреть файл

@@ -46,7 +46,7 @@ namespace JT808.Gateway.SimpleServer.Impl
//转发数据(可同步也可以使用队列进行异步) //转发数据(可同步也可以使用队列进行异步)
try try
{ {
jT808TransmitService.Send(parameter);
jT808TransmitService.SendAsync(parameter);
} }
catch (Exception ex) catch (Exception ex)
{ {


+ 8
- 13
simples/JT808.Gateway.SimpleServer/JT808.Gateway.SimpleServer.csproj Просмотреть файл

@@ -5,23 +5,17 @@
<TargetFramework>netcoreapp3.1</TargetFramework> <TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <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.FileExtensions" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" 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.Hosting" Version="3.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" 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>
<ItemGroup> <ItemGroup>
<None Update="appsettings.json"> <None Update="appsettings.json">
@@ -29,4 +23,5 @@
</None> </None>
</ItemGroup> </ItemGroup>



</Project> </Project>

+ 14
- 0
simples/JT808.Simples.sln Просмотреть файл

@@ -13,6 +13,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.SimpleServer"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.SimpleClient", "JT808.Gateway.SimpleClient\JT808.Gateway.SimpleClient.csproj", "{09AFAC3E-4E4D-4B51-962D-BF8489D8BEC6}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JT808.Gateway.SimpleClient", "JT808.Gateway.SimpleClient\JT808.Gateway.SimpleClient.csproj", "{09AFAC3E-4E4D-4B51-962D-BF8489D8BEC6}"
EndProject 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 Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU 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}.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.ActiveCfg = Release|Any CPU
{09AFAC3E-4E4D-4B51-962D-BF8489D8BEC6}.Release|Any CPU.Build.0 = 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 EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@@ -44,6 +56,8 @@ Global
{CCE6AEFB-1AB0-4BD9-8EA2-8B4CDD097E88} = {2459FB59-8A33-49A4-ADBC-A0B12C5886A6} {CCE6AEFB-1AB0-4BD9-8EA2-8B4CDD097E88} = {2459FB59-8A33-49A4-ADBC-A0B12C5886A6}
{98E1CDD0-4D4E-48FE-968E-260F0CD5F4D3} = {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} {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 EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FC0FFCEA-E1EF-4C97-A1C5-F89418B6834B} SolutionGuid = {FC0FFCEA-E1EF-4C97-A1C5-F89418B6834B}


Загрузка…
Отмена
Сохранить