ZayniFramework.Middle.Service
2.2.1
See the version list below for details.
dotnet add package ZayniFramework.Middle.Service --version 2.2.1
NuGet\Install-Package ZayniFramework.Middle.Service -Version 2.2.1
<PackageReference Include="ZayniFramework.Middle.Service" Version="2.2.1" />
paket add ZayniFramework.Middle.Service --version 2.2.1
#r "nuget: ZayniFramework.Middle.Service, 2.2.1"
// Install ZayniFramework.Middle.Service as a Cake Addin #addin nuget:?package=ZayniFramework.Middle.Service&version=2.2.1 // Install ZayniFramework.Middle.Service as a Cake Tool #tool nuget:?package=ZayniFramework.Middle.Service&version=2.2.1
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.1)
- ZayniFramework.DataAccess (>= 2.2.1)
- ZayniFramework.Logging (>= 2.2.1)
- ZayniFramework.Middle.Service.Entity (>= 2.2.1)
- 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 | 213 | 3/19/2024 |
8.0.141 | 239 | 1/4/2024 |
8.0.140 | 282 | 12/17/2023 |
6.0.138 | 282 | 3/19/2024 |
6.0.137 | 512 | 9/20/2023 |
6.0.136 | 496 | 9/14/2023 |
6.0.135 | 528 | 9/10/2023 |
6.0.134 | 616 | 7/12/2023 |
6.0.133 | 595 | 7/10/2023 |
6.0.132 | 612 | 7/7/2023 |
6.0.131 | 687 | 6/19/2023 |
6.0.130 | 656 | 6/19/2023 |
6.0.129 | 11,757 | 7/2/2022 |
6.0.128 | 1,776 | 1/16/2022 |
6.0.127 | 1,689 | 1/15/2022 |
6.0.126 | 1,779 | 1/15/2022 |
6.0.125 | 1,090 | 1/8/2022 |
6.0.125-hotfix1 | 597 | 1/8/2022 |
6.0.124 | 1,126 | 1/7/2022 |
6.0.123 | 1,341 | 11/14/2021 |
5.0.129 | 2,387 | 7/2/2022 |
5.0.128 | 2,504 | 1/16/2022 |
5.0.125 | 1,395 | 1/8/2022 |
5.0.124 | 1,377 | 1/7/2022 |
5.0.123 | 1,706 | 11/14/2021 |
5.0.122 | 1,869 | 10/11/2021 |
5.0.121 | 1,903 | 5/1/2021 |
3.1.137 | 925 | 9/20/2023 |
3.1.136 | 891 | 9/14/2023 |
3.1.135 | 893 | 9/10/2023 |
3.1.134 | 1,049 | 7/12/2023 |
3.1.133 | 1,083 | 7/11/2023 |
3.1.132 | 1,052 | 7/8/2023 |
3.1.131 | 1,155 | 6/19/2023 |
3.1.130 | 1,933 | 2/1/2023 |
3.1.129 | 3,501 | 7/2/2022 |
3.1.128 | 3,703 | 1/16/2022 |
3.1.125 | 1,954 | 1/8/2022 |
3.1.124 | 1,873 | 1/7/2022 |
3.1.123 | 2,434 | 11/14/2021 |
3.1.122 | 2,746 | 10/11/2021 |
3.1.121 | 2,826 | 5/1/2021 |
2.31.120 | 1,892 | 3/14/2021 |
2.30.115 | 5,527 | 3/6/2021 |
2.30.114 | 1,826 | 3/6/2021 |
2.20.101 | 2,519 | 3/1/2021 |
2.19.3 | 1,896 | 2/11/2021 |
2.19.2 | 14,192 | 2/6/2021 |
2.19.1 | 2,148 | 1/6/2021 |
2.19.0 | 2,157 | 1/1/2021 |
2.18.3 | 3,480 | 12/27/2020 |
2.18.2 | 4,351 | 8/29/2020 |
2.18.1 | 7,589 | 8/26/2020 |
2.18.0 | 7,799 | 8/20/2020 |
2.17.135 | 3,566 | 8/19/2020 |
2.17.134 | 3,659 | 7/28/2020 |
2.17.133 | 3,656 | 7/27/2020 |
2.17.132 | 3,595 | 7/18/2020 |
2.17.131 | 3,765 | 7/11/2020 |
2.16.130 | 3,450 | 6/13/2020 |
2.15.128 | 3,651 | 6/3/2020 |
2.15.127 | 3,611 | 5/31/2020 |
2.15.126 | 4,518 | 4/30/2020 |
2.14.122 | 3,357 | 4/13/2020 |
2.13.100 | 3,516 | 3/12/2020 |
2.12.51 | 3,491 | 2/18/2020 |
2.11.50 | 7,604 | 2/10/2020 |
2.10.44 | 9,057 | 1/30/2020 |
2.9.43 | 9,013 | 1/11/2020 |
2.8.42 | 9,049 | 1/10/2020 |
2.8.41 | 9,017 | 1/5/2020 |
2.7.40 | 8,877 | 1/2/2020 |
2.7.39 | 8,730 | 1/2/2020 |
2.7.38 | 9,100 | 1/1/2020 |
2.6.37 | 8,957 | 12/23/2019 |
2.6.35 | 9,207 | 12/4/2019 |
2.6.1 | 9,008 | 12/2/2019 |
2.6.0 | 8,843 | 11/28/2019 |
2.5.2 | 9,351 | 11/26/2019 |
2.5.1 | 8,971 | 11/12/2019 |
2.5.0 | 8,737 | 11/9/2019 |
2.4.3 | 9,297 | 10/16/2019 |
2.4.2 | 8,765 | 10/16/2019 |
2.4.1 | 8,974 | 9/20/2019 |
2.3.113 | 1,854 | 3/6/2021 |
2.3.112 | 1,788 | 3/6/2021 |
2.3.28 | 8,809 | 9/19/2019 |
2.3.27 | 8,920 | 8/30/2019 |
2.3.26 | 8,920 | 8/20/2019 |
2.3.25 | 8,819 | 8/12/2019 |
2.3.22 | 8,932 | 7/31/2019 |
2.3.21 | 8,819 | 7/20/2019 |
2.3.20 | 8,416 | 6/22/2019 |
2.3.19 | 8,929 | 6/14/2019 |
2.3.18 | 8,945 | 6/13/2019 |
2.3.17 | 8,987 | 6/13/2019 |
2.3.15 | 8,540 | 6/8/2019 |
2.3.14 | 8,697 | 6/8/2019 |
2.3.13 | 8,797 | 5/30/2019 |
2.3.12 | 4,323 | 5/24/2019 |
2.3.11 | 4,229 | 5/24/2019 |
2.3.10 | 4,228 | 5/21/2019 |
2.3.9 | 4,072 | 5/9/2019 |
2.3.8 | 4,467 | 5/8/2019 |
2.3.7 | 4,312 | 4/30/2019 |
2.3.6 | 4,394 | 4/23/2019 |
2.3.5 | 4,361 | 4/19/2019 |
2.3.4 | 4,250 | 4/18/2019 |
2.3.3 | 4,223 | 4/17/2019 |
2.3.2 | 4,449 | 4/6/2019 |
2.3.1 | 4,402 | 12/15/2018 |
2.3.0 | 4,395 | 12/7/2018 |
2.2.7 | 3,507 | 11/30/2018 |
2.2.6 | 4,631 | 11/25/2018 |
2.2.5 | 3,804 | 11/23/2018 |
2.2.4 | 3,602 | 11/22/2018 |
2.2.3 | 2,845 | 11/21/2018 |
2.2.2 | 2,656 | 11/19/2018 |
2.2.1 | 2,242 | 11/17/2018 |
2.2.0 | 1,897 | 11/16/2018 |
2.1.0 | 1,784 | 11/15/2018 |
2.0.1 | 1,092 | 11/6/2018 |
2.0.0 | 1,201 | 11/4/2018 |