是否可以通过使用namedPipe 绑定的oneWay 调用来保证有序交付?
我有一个使用namedPipe 绑定进行通信的WCF 服务/客户端。客户端公开一个回调合约,其中回调中的所有方法都标记为 OneWay。像这样的事情
[ServiceContract(CallbackContract = typeof(IMyServiceCallback))]
public interface IMyService
{
[OperationContract]
void MyOperation();
}
public interface IMyServiceCallback
{
[OperationContract(IsOneWay=true)]
void MyCallback1();
[OperationContract(IsOneWay=true)]
void MyCallback2();
}
在服务器端,MyOperation方法的实现总是首先调用MyCallback1,然后调用MyCallback2,但我观察到有时客户端以不正确的顺序接收调用(首先是MyCallback2,然后是MyCallback1)。
在互联网上搜索时,我发现单向操作不能保证顺序,如此处所述,而且还有一些东西称为 reliableSession 确保消息排序。
Internet 上可靠会话的所有示例都使用 TCP 绑定(而不是使用 NamedPipeBinding 的单个示例),并且 tcpBinding 还具有一个名为 ReliableSession。所以我不确定可靠会话是否可以与 NetNamedPipeBinding 一起使用。
问题:
可靠会话可以与namedPipeBinding一起使用吗?如果是,怎么办?如果没有,是否有其他方法可以保证订单交付?
Is it possible to guarantee ordered delivery with oneWay calls using namedPipe binding?
I have a WCF service/client communicating using namedPipe binding. The client is exposing a callback contract in which all the methods in the callback are marked as OneWay. Something like this
[ServiceContract(CallbackContract = typeof(IMyServiceCallback))]
public interface IMyService
{
[OperationContract]
void MyOperation();
}
public interface IMyServiceCallback
{
[OperationContract(IsOneWay=true)]
void MyCallback1();
[OperationContract(IsOneWay=true)]
void MyCallback2();
}
At the server side, the implementation of MyOperation method always calls MyCallback1 first and then MyCallback2 but I am observing that sometimes the client receives the calls in the incorrect order (MyCallback2 first and then MyCallback1).
On searching the internet I found that the order is not guaranteed with oneway operation as mentioned here and also there is something called reliableSession which ensure message ordering.
All the examples on the internet for reliable session are with TCP binding (and not a single one with NamedPipeBinding) and the tcpBinding also has a property called ReliableSession which is not present on the NetNamedPipeBinding. So I am not sure whether reliable session is expected to work with NetNamedPipeBinding or not.
Question:
Does reliable session work with namedPipeBinding? If yes, how? If no, Is there any other approach with which I can guarantee ordered delivery?
发布评论
评论(1)
http://msdn.microsoft.com/en-us/library/aa480191。 ASPX
您的消息很可能按照服务器发送消息的顺序进行传送,而后者正是您需要处理的内容。服务器可能同时运行,并且不保证有序调度。
话又说回来,我可能是错的。从上面的链接中,您可以指定一些属性关于控制订购交付的合同和实施。
这个问题也有一些更多信息。
http://msdn.microsoft.com/en-us/library/aa480191.aspx
Chances are, your messages are being delivered in the order the server sends them, and the latter is what you need to work with. The server may be running concurrently and offer no guarantee for ordered dispatch.
Then again, I could be wrong. From my link above, there are some attributes you can specify on your contract and implementation that control ordered delivery.
This question has some more information as well.