.NET 远程处理 - 重定向消息/主机冗余
我正在尝试在 .NET Remoting 中完成某种形式的消息重定向。
您在图片中看到的,我希望客户端向提供者发送一条消息(这是客户端必须了解的唯一 URI),然后提供者会将其重定向到 host1。这是棘手的部分;提供程序将跟踪哪个主机处于活动状态(通过向主机公开注册/取消注册远程处理方法),换句话说,提供程序必须能够动态更改它将消息重定向到哪个 URI。
我一直试图通过在客户端向其发送消息的提供程序中创建一个主机,然后在提供程序中创建一个实现自定义代理的客户端(通过继承 RealProxy),将消息重定向到当前首选主持人。然而,我不断地回到关于动态更改 URI 的问题,我感觉我只是错过了一些简单但至关重要的部分,这些部分将解决这个问题,而不会将其变成一个毛茸茸的大怪物。
任何提示/提示将不胜感激!
I'm trying to accomplish some form of redirection of messages in .NET Remoting.
As you can see in the image I would like for the client to send a message to the provider (which is the only URI that the client has to know about), which will then redirect this to host1. Here's the tricky part; the provider will keep track of which host is alive (by exposing a register/unregister remoting-method to the hosts), in other words the provider has to be able to dynamically change which URI it should redirect the message to.
I have been attempting to solve the problem by creating a host in the provider that the client sends messages to, and then a client (in the provider) that implements a custom proxy (by inheriting from RealProxy) that will redirect messages to the currently preferred host. However, I keep coming back to the problem about dynamically changing URI and I get the feeling that I'm just missing some easy, but vital, part that will solve this problem without turning it into a big hairy monster.
Any tips/hints will be much appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了供将来参考,我对此采取了另一种简化的方法。提供程序将被删除,而客户端将尝试直接访问 host1。如果出现 SocketException(主机未回复时会出现这种情况),请将其隔离 X 分钟,然后尝试使用下一个主机。如果所有主机均已关闭,则重新抛出异常。
For future reference, I'm taking another, simplified, approach on this. The provider will be removed and instead the client will try to access host1 directly. In case of a SocketException, which is what it will get when the host doesn't reply, then put it in quarantine for X minutes and try with the next host. If all hosts are down, re-throw the exception.