具有订阅者缓存的 WCF Pub/Sub [英] WCF Pub/Sub with subscriber caching

查看:45
本文介绍了具有订阅者缓存的 WCF Pub/Sub的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题:如何使用 WCF 提供分布式、可扩展和抗灾难的发布/订阅服务.

Problem: how to provide a distributed, scalable and disaster resistant pub/sub service with WCF.

详情:

请注意,除了消息传递/中间件解决方案(例如 Tibco EMS)之外,正在考虑使用这种方法.

我一直在研究 WCF,特别是如何使用它来提供发布/订阅服务.关于这个主题,这篇文章非常好:WCF pub-sub.

I've been looking into WCF, particularly how it may be used to offer pub/sub. On this subject this article is very good: WCF pub-sub.

在这篇文章中,作者试图解决拥有多个发布者的问题(就像一个服务层跨多个框缩放一样).问题在于,如果客户端 A 向发布者 A 注册但发布者 B 希望发布事件,那么发布者 B 将不知道客户端 A.即没有人告诉发布者 B,客户端 A 想要收到有关事件的通知.作者建议使用 pub/sub 服务作为解决方案.发布/订阅服务将集中存储订阅.但是,如果我想通过二级/双发布/订阅服务使发布/订阅服务具有抗灾难性,那么我会遇到同样的原始问题.

In the article the author attempts to tackle the problem of having multiple publishers (as one would have with a service layer scaled across several boxes). The problem being that if client A registers with Publisher A but Publisher B wishes to publish an event, then publisher B won't know about client A. i.e. no one told publisher B that client A wanted to be notified about events. The author suggests a pub/sub service as a solution. The pub/sub service would centrally store subscriptions. However, if I wanted to make the pub/sub service disaster resistant by having a secondary/dual pub/sub service then I have the same original problem.

所以,我认为有几个解决方案:

So, I think there are a couple of solutions to the problem:

  1. 将订阅者详细信息存储在分布式缓存中(请参阅问题:q1q2).
  2. 将订阅者详细信息存储在数据库/中央文件系统中.

谁能想到任何其他解决方案(即我没有错过 WCF 的一些奇妙的神奇功能?)任何意见表示赞赏.

Can anyone think of any other solutions (i.e. I've not missed some fantastic magical feature of WCF?) Any comments appreciated.

推荐答案

我遇到了同样的问题,我对这个问题做了很多研究.问题其实很简单.你想保持一些集中的状态,但是以分布式的方式.我发现实现这一目标的最佳方法是使用分布式缓存.以速度为例.我知道没有可以解决状态管理问题的本机 WCF 解决方案.我什至研究过持久服务,其中状态管理由 WCF 处理,但不适合发布/订阅服务,因为所有客户端连接的状态都需要集中.将数据存储在数据库中也是一种选择,但代价是需要一个数据库,即使有一个数据库,如果数据库不是跨多台机器集群,也会出现单点故障.

I had the same problem and I did a lot of research on the issue. The problem is actually simple. You want to keep some centralized state, but in distributed way. I found that the best way to achieve this is by using a distributed cache. Look at velocity for example. There is no native WCF solution that I know that can solve the state management issue. I have even looked into durable services, where state management is handled by WCF, however not suitable for a pub/ sub service, because the state needs to be centralized for all client connections. Storing data in a database is also an option, but the cost is the need for a database, and even with a database you can have a single point of failure if the database is not clustered accorss multiple machines.

最后,我认为实现零故障点的东西实际上是昂贵的,如果你决定去那里然后看看 Azure,存储的未来在云上,Azure 服务将完全可扩展和分布式,但我们还没有做到这一点.

At the end, I figured it is actually expensive to implement something with zero points of failure and if you do decide to go there then take a look at Azure, the future of storage is on the cloud, Azure services will be fully scalable and distributed, but we are not there yet.

这篇关于具有订阅者缓存的 WCF Pub/Sub的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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