实现使用WCF观察者模式 [英] Implementing observer pattern using WCF

查看:270
本文介绍了实现使用WCF观察者模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我第一次张贴了这个问题,我有我的Web服务,并在需要的控制器开启多线程的服务,并收到回的数据就不得不做大量的处理上返回的数据应用控制器之间的强耦合它合并成一个数据集。我不喜欢的事实,客户有这么多的处理和合并返回的数据之前,它已准备好使用,并希望该层移动到服务,让服务打开异步线程的供应商和合并结果在他们之前返回到客户端。

When I first posted this question I had strong coupling between my web service and application controller where the controller needed to open multiple threads to the service and as it received back data it had to do a lot of processing on the returned data and merge it into one dataset. I did not like the fact that the client had to so much processing and merge the returned data before it was ready to be used and wanted to move that layer to the service and let the service open the asynchronous threads to the suppliers and merge the results before returning them to the client.

一个挑战我的是,我不能等到所有线程都完成,结果被合并,我不得不开始接收数据,因为它是可用的。这给我打电话来实现对服务的观察者模式,这样它会通知我的应用程序时,新的结果集进行合并,并随时可以使用,并将它们发送到应用程序。

One challenge I had was that I could not wait till all threads were complete and results were merged, I had to start receiving data as it was available. That called me to implement an observer pattern on the service so that it would notify my application when new set of results are merged and ready to be used and send them to the application.

我一直在寻找如何利用无论是在ASMX Web服务或WCF,到目前为止,我发现使用WCF实现它这样做,但这个线程始终是敞开的建议和改进。

I was looking for how to do this using either on ASMX webservices or WCF and so far I have found implementing it using WCF but this thread is always open for suggestions and improvements.

推荐答案

确定解决我的问题来自的 WCF

OK the solution to my problem came from WCF

在除了ASMX web服务经典请求 - 应答操作,WCF支持附加操作类型喜欢;单向通话,双工回调和流媒体。

In addition to classic request-reply operation of ASMX web services, WCF supports additional operation types like; one-way calls, duplex callbacks and streaming.

不是太难猜,双工回调是我所期待的。

Not too hard to guess, duplex callback was what I was looking for.

复式回调干脆让服务做回调到客户端。回调合同在服务器上定义和客户需要提供在每次调用回调端点。然后,它是到服务来决定多少次时和使用回调参考

Duplex callbacks simply allow the service to do call backs to the client. A callback contract is defined on the server and client is required to provide the callback endpoint on every call. Then it is up to the service to decide when and how many times to use the callback reference.

只有器Bidirectiona能力绑定的支持回调操作。 WCF提供了WSDualHttpBinding支持回调通过HTTP(回调支持也存在由NetNamedPipeBinding和NetTcpBinding的TCP和IPC协议支持全双工通信)

Only bidirectiona-capable bindings support callback operations. WCF offers the WSDualHttpBinding to support callbacks over HTTP (Callback support also exists by NetNamedPipeBinding and NetTcpBinding as TCP and IPC protocols support duplex communication)

这里要注意一个非常重要的事情是,双工回调是非标准和纯微软功能。这不是在手,我的两个Web服务和应用程序中创建对我目前的工作问题,在Microsoft ASP.NET运行

One very important thing to note here is that duplex callbacks are nonstandard and pure Microsoft feature. This is not creating a problem on my current task at hand as both my web service and application are running on Microsoft ASP.NET

编程给了我在WCF一个不错的跳跃开始WCF服务。作为超过700页再往深入到所有的WCF consepts并有一个专门的章节对回调和其他类型的操作。

Programming WCF Services gave me a good jump start on WCF. Being over 700 pages it delves deep into all WCF consepts and has a dedicated chapter on the Callback and other type of operations.

其他的一些很好的资源,我发现在网上有;

Some other good resources I found on the net are;

Windows通讯基础(WCF)截屏

<一个href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?culture=en-US&EventID=1032344313&Country$c$c=US"相对=nofollow> MSDN网络广播:Windows通信基础从上到下

Web服务软件工厂

服务工厂的WCF

这篇关于实现使用WCF观察者模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆