简体   繁体   English

WCF双工通道,用于进程间通信

[英]WCF duplex channel for inter-process communication

I have system like this: 我有这样的系统:

Windows service (WCF, data/events) <-> Web app <-> Web client Windows服务(WCF,数据/事件)<-> Web应用程序<-> Web客户端

I need simultaneous response for clients requests. 我需要客户请求的同时响应。 I have some events from service for clients too. 我也有一些服务于客户的事件。 So duplex channel is the way to go. 因此,双工通道是必经之路。 But I need high throughput, because clients calls simultaneously. 但是我需要高吞吐量,因为客户端会同时通话。

Request/reply approach 请求/回复方式

In order not to serialize channel requests I need more channels for parallel calls, right? 为了不序列化通道请求,我需要更多通道进行并行调用,对吗? But how to handle callback channel then? 但是如何处理回调通道呢? Ho to keep it still open for receiving events, even on channel errors? 哪怕在出现通道错误时也要保持打开状态以接收事件?

OneWay approach 单向方法

On channel should be enough (no waiting for data preparation), but how to link data sent to callback with original request, to be able to compose response for client? 在通道上应该足够(无需等待数据准备),但是如何将发送给回调的数据与原始请求链接起来,以便能够为客户端编写响应?

What is the way to go? 怎么走? Thank you. 谢谢。

In a simple case, when a web client sends a request to the web app, and web app (possibly) sends a request(s) to WCF service, there's no need in duplex binding at all. 在一个简单的情况下,当Web客户端向Web应用程序发送请求,并且Web应用程序(可能)向WCF服务发送请求时,根本不需要双向绑定。

As for events, raised by the service to be fired in Web client, I'd suggest to use a message broker which supports WebSockets - for example RabbitMQ . 至于由Web客户端中触发的服务引发的事件,我建议使用支持WebSockets消息代理 -例如RabbitMQ It has a plugin compatible with WebSockets and WCF binding . 它具有与WebSockets和WCF绑定兼容的插件

Putting things together, one can create a RabbitMQ server, which accepts messages from WCF service and sends it to Web client, which subscribes to the event feed from Javascript . 放在一起,可以创建RabbitMQ服务器,该服务器从WCF服务接收消息并将其发送到Web客户端,该客户端从Java订阅事件提要。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM