如何保证单向方法的可靠性?
关于单向调用、回调和事件您需要了解的内容 文章讲述:
客户端不关心调用结果的事实并不意味着客户端根本不关心调用是否发生。一般来说,您应该打开服务的可靠性,即使是单向调用
我也尝试过如何启用可靠性,但没有发现任何有意义的东西。
您能帮我吗:
- 如何实现可靠性?
- 如何检查单向方法是否到达服务器?
多谢!
The What You Need To Know About One-Way Calls, Callbacks, And Events article tells:
The fact that the client doesn't care about the result of the invocation does not mean the client doesn't care if the invocation took place at all. In general, you should turn on reliability for your services, even for one-way calls
I've tried to find how can I enable reliability, but didn't find anything meaningful.
Could you please help me:
- How to enable reliability?
- How to check if one-way method reached server?
Thanks a lot!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我假设您指的是 Juval Lowy 的“编程 WCF 服务”中描述的消息可靠性 - the您链接的文章的作者(因此该引用也逐字出现在书中)。
可靠性仅在某些绑定上有效。以这个 TCP 绑定为例。在您的配置文件中:
为了检查可靠性,我将引用这本书(第 66 页):
我不知道发件人如何知道,我从未遇到过它,但希望它能给您更多的见解,以便更深入地研究该主题。
进一步阅读:
http://msdn.microsoft.com/en-us/library/ ms733136.aspx
I'm going to assume you mean Message Reliability as described in "Programming WCF Services" by Juval Lowy - the author of your linked article (and consequently that quote appears, word for word, in the book too).
Reliability is only valid on certain bindings. Take this TCP binding example. In your configuration file:
To check reliability I will quote the book (p. 66):
I've no idea how the sender will know, I've never encountered it, but hopefully it will give you some more insight to research the topic in more depth.
Further reading:
http://msdn.microsoft.com/en-us/library/ms733136.aspx
@Budda:是的,您不必在将每条消息发送到服务器后立即等待答案或确认。那将是同步操作。我相信你会使用异步操作:发送一条消息,稍后——当服务器收到确认时,或者当套接字告诉你传输失败时——你可以控制你的“回调”函数来告知错误,将消息从队列中取出,或者其他什么。这样,您就可以避免发生您理应担心的大事。但现在我已经给出了一个可能令人困惑的答案,我发现整个问题都围绕着 wcf,直到此刻我才听说过它。所以,如果我搅浑了水,我深表歉意。也许wcf中有异步通信;总的来说,如果可能的话,我认为这是可行的方法。也许这就是“单向通讯”的含义。
@Budda: that's right, you don't have to wait for an answer or acknowledgment immediately after sending every single message to the server. That would be synchronous operation. I believe you would use asynchronous operation: a message is sent and sometime later -- when the acknowledgment arrives from the server, or when the socket tells you the transmit failed -- you get control in your "callback" function to tell about the error, take the message off the queue, or whatever. That way, you avoid the big deal that you are rightly worried about. BUT now that I've jumped in with a possibly-confusing answer, I see that the whole question is around wcf, which I've never heard of till this very moment. So, if I've muddied the waters, I apologize. Perhaps there's asynchronous comm in wcf; in general, I'd think that's the way to go if it's possible. Maybe that's what "one-way comm" means.
通常,如果您需要 OneWay 操作和可靠性,这是您正在构建基于队列的机制的一个好兆头。客户端将消息放入队列,工作人员挑选消息并处理它们。
也许您可以看一下 MSMQ,看看它是否可以帮助您。
大多数时候,OneWay 操作不应该携带重要的任务或信息,因为它们本质上不能保证由服务器处理。当消息已由服务端的调度程序路由时,OneWay 调用将在客户端返回。有了调度员之后,你就没有任何可靠性了。
Usually if you need OneWay operations and reliability, it is a good sign that you are building a queue based mechanism. Client puts message in queue, workers pick the messages and process them.
Maybe you could have a look at MSMQ and see if it can help you.
Most of the time, OneWay operations should not carry an important task or information because they are inherently not guaranteed to be processed by the server. The OneWay calls returns on the client side when the message has been routed by the dispatcher on the service side. After the dispatcher, you have no reliability whatsoever.