.NET Scalable Pub/Sub service implementation

我的未来我决定 提交于 2019-12-04 17:17:24

If the question is how to bridge SignalR with other transports there are several solutions.

On a single server you could just connect them up with the Reactive framework's own pubsub mechanism which is neatly encapsulated in the Subject class.

If you need to scale out to multiple servers you'll want to use an existing service bus or perhaps roll your own simple one using SQL server and a SqlDependency.

You could also use SignalR as a client on one server communicating with the other servers to copy messages between them.

I recommend you look into some of the existing Service Bus technologies for .NET.

There is an article which clearly explains the possible mechanism of how to incorporate a pub/sub design pattern in your .NET application. The answer lies in using a .NET In-Memory distributed cache and use its clustering capabilities as a publish subscribe medium. Since it's clustered therefore you won't have to worry about down-times as well.

Basically you'll be using the Application Initiated Custom Events

Register your events

public void OnApplicationEvent(object notifId, object data)
{
  ...
} 
_cache.CustomEvent += new CustomEventCallback(this.OnApplicationEvent);

And fire those events whenever you need to

_cache.RaiseCustomEvent("NotificationID", DateTime.Now);

Pub/Sub design pattern in a .NET distributed cache

Full disclosure: I work for Alachisoft

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!