Using SignalR with Redis messagebus failover using BookSleeve's ConnectionUtils.Connect()

和自甴很熟 提交于 2019-12-02 16:54:07

The SignalR team has now implemented support for a custom connection factory with StackExchange.Redis, the successor to BookSleeve, which supports redundant Redis connections via ConnectionMultiplexer.

The initial problem encountered was that in spite of creating my own extension methods in BookSleeve to accept a collection of servers, fail-over was not possible.

Now, with the evolution of BookSleeve to StackExchange.Redis, we can now configure collection of servers/ports right in the Connect initialization.

The new implementation is much simpler than the road I was going down, in creating a UseRedisCluster method, and the back-end pluming now supports true fail-over:

var conn = ConnectionMultiplexer.Connect("redisServer1:6380,redisServer2:6380,redisServer3:6380,allowAdmin=true");

StackExchange.Redis also allows for additional manual configuration as outlined in the Automatic and Manual Configuration section of the documentation:

ConfigurationOptions config = new ConfigurationOptions
{
    EndPoints =
    {
        { "redis0", 6379 },
        { "redis1", 6380 }
    },
    CommandMap = CommandMap.Create(new HashSet<string>
    { // EXCLUDE a few commands
        "INFO", "CONFIG", "CLUSTER",
        "PING", "ECHO", "CLIENT"
    }, available: false),
    KeepAlive = 180,
    DefaultVersion = new Version(2, 8, 8),
    Password = "changeme"
};

In essence, the ability to initialize our SignalR scale-out environment with a collection of servers now solves the initial problem.

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