How to enable reliability for one-way methods?
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!
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:
<binding>
<netTcpBinding>
<binding name="MyTcpBinding">
<reliableSession enabled="true" />
</binding>
</netTcpBinding>
</binding>
To check reliability I will quote the book (p. 66):
Message reliability does not guarantee message delivery. All it provides is a guarantee that if the message does not reach its destination, the sender will know about it.
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: 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.
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.
精彩评论