ZayniFramework.Middle.Service
2.2.3
See the version list below for details.
dotnet add package ZayniFramework.Middle.Service --version 2.2.3
NuGet\Install-Package ZayniFramework.Middle.Service -Version 2.2.3
<PackageReference Include="ZayniFramework.Middle.Service" Version="2.2.3" />
paket add ZayniFramework.Middle.Service --version 2.2.3
#r "nuget: ZayniFramework.Middle.Service, 2.2.3"
// Install ZayniFramework.Middle.Service as a Cake Addin #addin nuget:?package=ZayniFramework.Middle.Service&version=2.2.3 // Install ZayniFramework.Middle.Service as a Cake Tool #tool nuget:?package=ZayniFramework.Middle.Service&version=2.2.3
Middleware ServiceHost example.
The Middle.ServiceHost is a self-host application middleware service module. Any kind of .NET application can add package reference of the ZayniFramework.Middle.Service nupkg, then your application will be able to serve any clinet-side application by using this middleware serivce.
First, add a serviceHostConfig.json config file in your app project.<br/> You can use TCPSocket, WebSocket or RabbitMQ protocol. Each of them support RPC (Request & Response), Message Publish and Service Event Listening.
Something like this...
{
"enableConsoleTracingLog": true,
"serviceHosts": [
{
"serviceName": "PaymentService",
"remoteHostType": "TCPSocket",
"hostName": "GCP-Production",
"enableActionLogToDB": true,
"enableActionLogToFile": true
},
{
"serviceName": "OrderService",
"remoteHostType": "RabbitMQ",
"hostName": "GCP-Production",
"enableActionLogToDB": true,
"enableActionLogToFile": true
},
{
"serviceName": "WealthManagementService",
"remoteHostType": "RabbitMQ",
"hostName": "Azure-Production",
"enableActionLogToDB": true,
"enableActionLogToFile": true
}
],
"tcpSocketHostSettings": {
"defaultHost": "GCP-Production",
"hosts": [
{
"hostName": "GCP-Production",
"tcpPort": 5590,
"tcpBufferSizeKB": 10
},
{
"hostName": "Azure-Production",
"tcpPort": 5590,
"tcpBufferSizeKB": 10
}
]
},
"webSocketHostSettings": {
"defaultHost": "GCP-Production",
"hosts": [
{
"hostName": "GCP-Production",
"hostBaseUrl": "ws://0.0.0.0:5580",
"whitelist": []
},
{
"hostName": "Azure-Production",
"hostBaseUrl": "ws://0.0.0.0:5580",
"whitelist": []
}
]
},
"rabbitMQSettings": {
"defaultHost": "Azure-Production",
"hosts": [
{
"hostName": "GCP-Production",
"mbHost": "XXX",
"mbPort": 5672,
"mbUserId": "XXX",
"mbPassword": "XXX",
"mbVHost": "SomeHost",
"msgRoutingKey": "Event.Client.",
"msgQueue": "Middle.Server.ListenClient.Msg",
"rpcQueue": "Middle.Server.RPC",
"rpcRoutingKey": "RPC.Server.",
"publishDefaultExchange": "Middle.Test.Topic",
"publishExchange": "Middle.Test.Topic",
"publishRoutingKey": "Event.Server."
},
{
"hostName": "Azure-Production",
"mbHost": "XXX",
"mbPort": 5672,
"mbUserId": "XXX",
"mbPassword": "XXX",
"mbVHost": "SomeHost",
"msgRoutingKey": "Event.Client.",
"msgQueue": "Middle.Server.ListenClient.Msg",
"rpcQueue": "Middle.Server.RPC",
"rpcRoutingKey": "RPC.Server.",
"publishDefaultExchange": "Middle.Test.Topic",
"publishExchange": "Middle.Test.Topic",
"publishRoutingKey": "Event.Server."
}
]
}
}
Then, write your DTO (Data Transfer Object) class for communication with outside applications.<br/> You can also use ZayniFramework.Validation's validation attribute on your DTO's properties.
using Newtonsoft.Json;
using System;
using ZayniFramework.Validation;
namespace ServiceHost.Test.Entity
{
/// <summary>Some DTO class
/// </summary>
[Serializable()]
public class SomethingDTO
{
/// <summary>Some message
/// </summary>
[NotNullOrEmpty( Message = "'someMsg' is invalid." )]
[JsonProperty( PropertyName = "someMsg" )]
public string SomeMessage { get; set; }
/// <summary>Some DateTime
/// </summary>
[JsonProperty( PropertyName = "someDate" )]
public DateTime SomeDate { get; set; }
/// <summary>Some double number
/// </summary>
[JsonProperty( PropertyName = "magicNumber" )]
public double SomeMagicNumber { get; set; }
/// <summary>Some Int32 number
/// </summary>
[JsonProperty( PropertyName = "luckyNumber" )]
public int LuckyNumber { get; set; }
/// <summary>Some boolean value
/// </summary>
[JsonProperty( PropertyName = "isSuperXMan" )]
public bool IsSuperMan { get; set; }
}
}
Then, you can write your ServiceAction in your own class library project.<br/> Add namespace using.
using ZayniFramework.Common;
using ZayniFramework.Logging;
using ZayniFramework.Middle.Service;
using ZayniFramework.Serialization;
Write your ServieAction class and extends ServiceAction abstract class.
/// <summary>Some Servie Action
/// </summary>
public class MagicTestAction : ServiceAction<SomethingDTO, Result<MagicDTO>>
Write your constructor and pass the action name to the base class.
/// <summary>Constructor.
/// </summary>
public MagicTestAction() : base( "MagicTestAction" )
{
// pass
}
Override the Execute method. You can implement your business logic here.<br/> See, your application don't know what kind of protocol or communication framework is using now. The only you need to focus is your business logic!
/// <summary>Execute Action. Your business logic here...
/// </summary>
public override void Execute()
{
Response = new Result<MagicDTO>()
{
IsSuccess = false,
Data = null
};
Logger.WriteInformationLog( this, $"Receive SomethingDTO is {Environment.NewLine}{JsonConvertUtil.SerializeInCamelCase( Request )}", nameof ( Execute ) );
SomethingDTO reqDTO = Request;
var resDTO = new MagicDTO()
{
MagicWords = $"You should not wake me up... {Guid.NewGuid().ToString()}",
MagicTime = DateTime.Now
};
if ( 7.77 == reqDTO.SomeMagicNumber )
{
resDTO.TestDouble = 999.999;
}
Response.Data = resDTO;
Response.IsSuccess = true;
}
Then, you need to inject your ServiceAction to the ServiceActionContainer.
MiddlewareService.InitializeServiceActionHandler = () =>
{
var magicTestAction = new MagicTestAction();
ServiceActionContainerManager.Add( "PaymentService", magicTestAction.Name, magicTestAction.GetType() );
ServiceActionContainerManager.Add( "OrderService", magicTestAction.Name, magicTestAction.GetType() );
return new Result() { IsSuccess = true };
};
Finally, you just need to start the Middle.ServiceHost service in your application.
var configPath = "./Configs/serviceHostConfig.json";
var r = new MiddlewareService().StartService( "PaymentService", path: configPath );
var j = new MiddlewareService().StartService( "OrderService", path: configPath );
More sample, you can go to Test/WebAPI.Test directory to see the complete sample code.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Newtonsoft.Json (>= 11.0.2)
- RabbitMQ.Client (>= 5.1.0)
- websocketsharp.core (>= 1.0.0)
- ZayniFramework.Common (>= 2.2.2)
- ZayniFramework.DataAccess (>= 2.2.1)
- ZayniFramework.Logging (>= 2.2.1)
- ZayniFramework.Middle.Service.Entity (>= 2.2.3)
- ZayniFramework.RabbitMQ.Msg.Client (>= 2.2.1)
- ZayniFramework.Serialization (>= 2.2.1)
- ZayniFramework.Validation (>= 2.2.1)
- ZeroFormatter (>= 1.6.4)
NuGet packages (4)
Showing the top 4 NuGet packages that depend on ZayniFramework.Middle.Service:
Package | Downloads |
---|---|
ZayniFramework.Middle.Service.Client
The Middle.Service.Client is the client SDK for Middle.Service module. You can use it to connect, send RPC request or publish message to the server side's service host very easy. Support TCPSocket, WebSocket and RabbitMQ protocol. GitLab Repository: https://gitlab.com/ponylin1985/zayniframework |
|
ZayniFramework.Middle.Service.Grpc
This is an extension module for Zayni Framework's Middle.Service module. This extension module provide the gRPC RemoteHost service implementation for Middle.Service module. GitLab Repository: https://gitlab.com/ponylin1985/zayniframework |
|
ZayniFramework.Middle.Service.HttpCore
This is an extension module for Zayni Framework's Middle.Service module. This extension module provide the HttpCoreRemoteHost implementation for Middle.Service module. This package support the .NET 6.0 or .NET Core target framework only. It doesn't support the .NET Framework projects. GitLab Repository: https://gitlab.com/ponylin1985/zayniframework |
|
ZayniFramework.Caching.RemoteCache
This is a ZayniFramework build-in Remote Share Data Service. You can use the ZayniFramework.Caching module to store data into this service. Also it support telnent service commands. GitLab Repository: https://gitlab.com/ponylin1985/ZayniFramework |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
8.0.142 | 215 | 3/19/2024 |
8.0.141 | 241 | 1/4/2024 |
8.0.140 | 284 | 12/17/2023 |
6.0.138 | 284 | 3/19/2024 |
6.0.137 | 514 | 9/20/2023 |
6.0.136 | 498 | 9/14/2023 |
6.0.135 | 530 | 9/10/2023 |
6.0.134 | 618 | 7/12/2023 |
6.0.133 | 597 | 7/10/2023 |
6.0.132 | 614 | 7/7/2023 |
6.0.131 | 689 | 6/19/2023 |
6.0.130 | 658 | 6/19/2023 |
6.0.129 | 11,759 | 7/2/2022 |
6.0.128 | 1,778 | 1/16/2022 |
6.0.127 | 1,691 | 1/15/2022 |
6.0.126 | 1,781 | 1/15/2022 |
6.0.125 | 1,092 | 1/8/2022 |
6.0.125-hotfix1 | 599 | 1/8/2022 |
6.0.124 | 1,128 | 1/7/2022 |
6.0.123 | 1,343 | 11/14/2021 |
5.0.129 | 2,389 | 7/2/2022 |
5.0.128 | 2,506 | 1/16/2022 |
5.0.125 | 1,397 | 1/8/2022 |
5.0.124 | 1,379 | 1/7/2022 |
5.0.123 | 1,708 | 11/14/2021 |
5.0.122 | 1,873 | 10/11/2021 |
5.0.121 | 1,905 | 5/1/2021 |
3.1.137 | 927 | 9/20/2023 |
3.1.136 | 893 | 9/14/2023 |
3.1.135 | 895 | 9/10/2023 |
3.1.134 | 1,051 | 7/12/2023 |
3.1.133 | 1,087 | 7/11/2023 |
3.1.132 | 1,054 | 7/8/2023 |
3.1.131 | 1,157 | 6/19/2023 |
3.1.130 | 1,935 | 2/1/2023 |
3.1.129 | 3,503 | 7/2/2022 |
3.1.128 | 3,705 | 1/16/2022 |
3.1.125 | 1,956 | 1/8/2022 |
3.1.124 | 1,875 | 1/7/2022 |
3.1.123 | 2,436 | 11/14/2021 |
3.1.122 | 2,748 | 10/11/2021 |
3.1.121 | 2,828 | 5/1/2021 |
2.31.120 | 1,894 | 3/14/2021 |
2.30.115 | 5,529 | 3/6/2021 |
2.30.114 | 1,830 | 3/6/2021 |
2.20.101 | 2,523 | 3/1/2021 |
2.19.3 | 1,898 | 2/11/2021 |
2.19.2 | 14,194 | 2/6/2021 |
2.19.1 | 2,150 | 1/6/2021 |
2.19.0 | 2,159 | 1/1/2021 |
2.18.3 | 3,482 | 12/27/2020 |
2.18.2 | 4,353 | 8/29/2020 |
2.18.1 | 7,591 | 8/26/2020 |
2.18.0 | 7,801 | 8/20/2020 |
2.17.135 | 3,568 | 8/19/2020 |
2.17.134 | 3,661 | 7/28/2020 |
2.17.133 | 3,658 | 7/27/2020 |
2.17.132 | 3,597 | 7/18/2020 |
2.17.131 | 3,767 | 7/11/2020 |
2.16.130 | 3,452 | 6/13/2020 |
2.15.128 | 3,653 | 6/3/2020 |
2.15.127 | 3,613 | 5/31/2020 |
2.15.126 | 4,520 | 4/30/2020 |
2.14.122 | 3,359 | 4/13/2020 |
2.13.100 | 3,518 | 3/12/2020 |
2.12.51 | 3,493 | 2/18/2020 |
2.11.50 | 7,606 | 2/10/2020 |
2.10.44 | 9,059 | 1/30/2020 |
2.9.43 | 9,015 | 1/11/2020 |
2.8.42 | 9,051 | 1/10/2020 |
2.8.41 | 9,019 | 1/5/2020 |
2.7.40 | 8,879 | 1/2/2020 |
2.7.39 | 8,732 | 1/2/2020 |
2.7.38 | 9,102 | 1/1/2020 |
2.6.37 | 8,959 | 12/23/2019 |
2.6.35 | 9,209 | 12/4/2019 |
2.6.1 | 9,010 | 12/2/2019 |
2.6.0 | 8,845 | 11/28/2019 |
2.5.2 | 9,353 | 11/26/2019 |
2.5.1 | 8,973 | 11/12/2019 |
2.5.0 | 8,739 | 11/9/2019 |
2.4.3 | 9,299 | 10/16/2019 |
2.4.2 | 8,767 | 10/16/2019 |
2.4.1 | 8,976 | 9/20/2019 |
2.3.113 | 1,856 | 3/6/2021 |
2.3.112 | 1,790 | 3/6/2021 |
2.3.28 | 8,811 | 9/19/2019 |
2.3.27 | 8,922 | 8/30/2019 |
2.3.26 | 8,922 | 8/20/2019 |
2.3.25 | 8,821 | 8/12/2019 |
2.3.22 | 8,934 | 7/31/2019 |
2.3.21 | 8,821 | 7/20/2019 |
2.3.20 | 8,418 | 6/22/2019 |
2.3.19 | 8,931 | 6/14/2019 |
2.3.18 | 8,947 | 6/13/2019 |
2.3.17 | 8,989 | 6/13/2019 |
2.3.15 | 8,542 | 6/8/2019 |
2.3.14 | 8,699 | 6/8/2019 |
2.3.13 | 8,799 | 5/30/2019 |
2.3.12 | 4,325 | 5/24/2019 |
2.3.11 | 4,231 | 5/24/2019 |
2.3.10 | 4,230 | 5/21/2019 |
2.3.9 | 4,074 | 5/9/2019 |
2.3.8 | 4,469 | 5/8/2019 |
2.3.7 | 4,314 | 4/30/2019 |
2.3.6 | 4,396 | 4/23/2019 |
2.3.5 | 4,363 | 4/19/2019 |
2.3.4 | 4,252 | 4/18/2019 |
2.3.3 | 4,225 | 4/17/2019 |
2.3.2 | 4,451 | 4/6/2019 |
2.3.1 | 4,404 | 12/15/2018 |
2.3.0 | 4,397 | 12/7/2018 |
2.2.7 | 3,511 | 11/30/2018 |
2.2.6 | 4,633 | 11/25/2018 |
2.2.5 | 3,806 | 11/23/2018 |
2.2.4 | 3,604 | 11/22/2018 |
2.2.3 | 2,847 | 11/21/2018 |
2.2.2 | 2,658 | 11/19/2018 |
2.2.1 | 2,244 | 11/17/2018 |
2.2.0 | 1,899 | 11/16/2018 |
2.1.0 | 1,786 | 11/15/2018 |
2.0.1 | 1,096 | 11/6/2018 |
2.0.0 | 1,203 | 11/4/2018 |