[英]WCF replacement for cross process/machine communication
I am working on a C# application that contains multiple windows services that will need to communicate with each other to pass data around. 我正在开发一个包含多个Windows服务的C#应用程序,这些服务需要相互通信才能传递数据。 These services may be on the same machine but they could be remote. 这些服务可能在同一台机器上,但它们可能是远程的。 I looked into using WCF for this purpose but it seems like WCF is too heavy and has a lot of extra configuration that, to me, seems unnecessary (.NET 3.5 is a requirement here, I know that .NET 4 simplified this) 我考虑使用WCF用于此目的,但看起来WCF太重了,并且有很多额外的配置,对我来说,似乎没必要(这里需要.NET 3.5,我知道.NET 4简化了这个)
So my question is, what would be the best replacement to WCF, besides the deprecated .NET Remoting that provide this functionality? 所以我的问题是,除了提供此功能的弃用的.NET Remoting之外,什么是WCF的最佳替代品?
I have been using PInvoke to access the Windows RPC runtime for nearly 8 years. 我已经使用PInvoke访问Windows RPC运行时近8年了。 It's wicked fast and very reliable as far as a transport goes. 就运输而言,这是快速且非常可靠的。 When combined with a fast serializer like protobuf-csharp-port the resulting communications are rock solid and very fast . 当与诸如protobuf-csharp-port之类的快速序列化器结合使用时,所产生的通信非常坚固且非常快速 。
So to build this from the ground-up this requires three parts: 因此,要从头开始构建它,这需要三个部分:
These are all available on NuGet in the following packages: Google.ProtocolBuffers , CSharpTest.Net.RpcLibrary , and Google.ProtocolBuffers.Rpc . 这些都可以在以下包中的NuGet上获得: Google.ProtocolBuffers , CSharpTest.Net.RpcLibrary和Google.ProtocolBuffers.Rpc 。
The following is a quick run-down on getting started: 以下是入门快速简化:
define a set of messages and a service using the Google Protocol Buffer Language . 使用Google协议缓冲区语言定义一组消息和服务。
Once you have that defined you will run ProtoGen.exe to generate the service stubs and messages in C#. 一旦定义了,您将运行ProtoGen.exe以在C#中生成服务存根和消息。 Be sure to add the "-service_generator_type=IRPCDISPATCH" to generate the correct service code. 请务必添加“-service_generator_type = IRPCDISPATCH”以生成正确的服务代码。
Now that you have the generated source files add them to a project and reference the three assemblies from the packages listed above. 现在您已将生成的源文件添加到项目中,并从上面列出的包中引用这三个程序集。
Lastly take a look at the sample client/server code on the protobuf-csharp-rpc project page. 最后,请查看protobuf-csharp-rpc项目页面上的示例客户端/服务器代码。 Replace the "SearchService" with your service name, and you should be ready to run. 将“SearchService”替换为您的服务名称,您应该已准备好运行。
Optionally change the configuration of the RPC client/server. (可选)更改RPC客户端/服务器的配置。 The example shows the use of LRPC which is local-host only; 该示例显示了仅使用本地主机的LRPC; however the DemoRpcLibrary.cs source file show TCP/IP and Named Pipes as well. 但DemoRpcLibrary.cs源文件也显示TCP / IP和命名管道。
You can always email me (roger @ my user name) for any further information or examples. 您可以随时给我发电子邮件(roger @我的用户名)以获取更多信息或示例。
Update 更新
I wrote a quick startup guide: WCF replacement for cross process/machine communication . 我写了一个快速启动指南: WCF替代跨进程/机器通信 。
You may want to look into ZeroMQ, it's very lightweight and effective and comes with good C# bindings. 你可能想要看看ZeroMQ,它非常轻巧和有效,并带有很好的C#绑定。 (Typing this on my mobile so you'll have to google for it yourself for now, sorry). (在我的手机上输入这个,所以你现在必须自己谷歌,对不起)。
It is way faster than WCF for coupled systems. 耦合系统比WCF快。
Interprocess communication with Glue Blog 与Glue博客进行进程间通信
Code: https://github.com/aumcode/nfx 代码: https : //github.com/aumcode/nfx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.