自定义 RPC、WCF 与 .NET 远程处理
我编写了一个简单的 RPC 类,可让我在 .net 桌面应用程序和 .net 服务器应用程序之间序列化和发送二进制数据。简而言之,客户端可以发送:
Dim Message as new TCPMessage
Message.Handler = "NewUser"
Message.AddField("FirstName", "Paul")
Message.AddField("Photo", PhotoBytes)
Message.Send()
服务器将在另一端重建数据:
Public Sub NewUser (Message As TCPMessage)
Dim FirstName as string = Message.GetString("FirstName")
Dim Photo() as Bytes = Message.GetBytes("Photo")
...
End Sub
这对于我目前正在做的事情来说一切正常 - 它看起来相当轻量级且高性能。
我想知道的是,通过 .NET Remoting / WCF 执行此操作的优点/缺点是什么?我对这些技术了解不多,但它们似乎更加灵活,但它们的性能也可能较低,并且需要相当长的学习曲线。
根据性能、学习曲线的标准,并记住没有其他人会维护代码,我应该继续使用我的 DIY 方案构建小型内部应用程序,还是尽快放弃它以使用远程处理/WCF?
编辑:性能是关键,客户端应用程序将定期接收约 200,000 行的数据集(是的,接收这么多数据是绝对必要的)。这一切都仅在 LAN 上运行。
I have written a simple RPC class that lets me serialize and send binary data between a .net desktop app and a .net server app. In a nutshell, a client could send:
Dim Message as new TCPMessage
Message.Handler = "NewUser"
Message.AddField("FirstName", "Paul")
Message.AddField("Photo", PhotoBytes)
Message.Send()
And the server would reconstruct the data on the other end:
Public Sub NewUser (Message As TCPMessage)
Dim FirstName as string = Message.GetString("FirstName")
Dim Photo() as Bytes = Message.GetBytes("Photo")
...
End Sub
This all works OK for what I'm doing at the moment – it seems pretty lightweight and performant.
What I would like to know is, what are the pros/cons of doing this instead through .NET Remoting / WCF? I don’t know much about these technologies, however it would appear that they are a lot more flexible, with the possibility that they may also be less performant and present a considerable learning curve.
On the criteria of performance, learning curve, and bearing in mind that no one else will be maintaining the code, should I continue to build small internal apps using my DIY scheme, or ditch it ASAP for Remoting/WCF?
Edit: Performance is key, the client apps will regularly be receiving datasets of ~200,000 rows (yes, it's absolutely necessary to receive this much data). This is all running on LAN only.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,.Net Remoting 现已被弃用,取而代之的是 WCF,请参阅 WCF 真的会取代 .Net Remoting吗? NET Remoting?
WCF 速度快且相对轻量。
WCF 的主要优点是它的可配置性很高。几乎只需进行配置更改,您就可以更改序列化格式、传输协议、身份验证机制、QOS 功能(可靠性/安全性/可扩展性)。它还具有足够的可扩展性,如果它不能提供您需要的内容,您可以自己添加。最后,它从通信代码中抽象出应用程序代码。
我肯定会在新项目中使用 WCF。我是否会从稳定、高性能、定制的解决方案中更改现有应用程序?这取决于更改的程度、现有解决方案的缺点以及 wcf 可能带来的潜在好处。
First off, .Net Remoting is now deprecated in favour of WCF, see Does WCF really replace .NET Remoting?
WCF is fast and relatively lightweight.
The key benefit of WCF though is that it is so configurable. Making pretty much only configuration changes, you can change serilaization format, transport protocol, authentication mechanism, QOS functionality (reliability/security/scalability). Its also extensible enough that if it doesn't provide what you need you can add it yourself. Finally it abstracts application code from communication code.
I'd definately use WCF for new projects. Would I change an existing application from a stable, performant, custom built solution? That depends on the extent of the change, the drawbacks of the existing solution and the potential benefits wcf could bring.