How to use SignalR in a webfarm, using Sql server

2019-01-26 00:46发布

Based on this topic signalr-sqlserver-listening, SignalR can be used in a webfarm, using Sql server as the backplane to communicate messages to all webnodes.

I wonder if there is any documentation/example on this.

1条回答
冷血范
2楼-- · 2019-01-26 00:50

There is an unreleased implementation of SignalR using SQL Server as Message Bus (backplane) that is in the works. You can view and compile the source from https://github.com/SignalR/SignalR/tree/master/src/Microsoft.AspNet.SignalR.SqlServer

Once you have a compiled version and make reference to the SignalR.SqlServer assembly in your project, you can enable the SQL Server backplane by invoking the following, typically from the Application_Start method in your global.asax.cs file.

 var connection = ConfigurationManager.ConnectionStrings["SignalRMessageBus"].ConnectionString;
 GlobalHost.DependencyResolver.UseSqlServer(connection);

This assumes you have defined the SignalRMessageBus connection string in your web.config file. The SignalR.SqlServer assembly will create the needed tables if they do not already exist in the database instance you are targeting with your connection string, so make sure the account you are accessing with has the permissions to create tables.

Again, this has not been officially released but according to the issue for this - Sql server scale out Message Bus this will be part of the upcoming 1.0 Alpha 1 release.

查看更多
登录 后发表回答