使用 oneWay 调用通过 NetNamedPipeBinding 进行有序交付

发布于 2024-10-09 09:41:39 字数 1233 浏览 7 评论 0 原文

是否可以通过使用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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

予囚 2024-10-16 09:41:39

http://msdn.microsoft.com/en-us/library/aa480191。 ASPX

Windows Communication Foundation 可靠消息传递简介

...

NetNamedPipeBinding 位于 Windows 操作系统之上,支持通过命名管道进行可靠的消息传递和可靠的流。由于命名管道是面向连接的、易于支持会话、设计可靠且通常不桥接,因此此绑定中不需要 WS-RM 支持

您的消息很可能按照服务器发送消息的顺序进行传送,而后者正是您需要处理的内容。服务器可能同时运行,并且不保证有序调度。

话又说回来,我可能是错的。从上面的链接中,您可以指定一些属性关于控制订购交付的合同和实施。

这个问题也有一些更多信息。

http://msdn.microsoft.com/en-us/library/aa480191.aspx

Introduction to Reliable Messaging with the Windows Communication Foundation

...

The NetNamedPipeBinding sits on top of the Windows operating system's support for reliable message delivery and reliable streams through named pipes. Because named pipes are connection-oriented, readily support sessions, are reliable by design, and are typically not bridged, there is no need for WS-RM support in this binding.

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文