Commit 0fdbf6eb authored by Savorboard's avatar Savorboard

support RabbitMQ cluster configuration.

parent 5a240305
......@@ -37,7 +37,10 @@ namespace DotNetCore.CAP
/// <summary> The topic exchange type. </summary>
public const string ExchangeType = "topic";
/// <summary>The host to connect to.</summary>
/// <summary>
/// The host to connect to.
/// If you want connect to the cluster, you can assign like “192.168.1.111,192.168.1.112”
/// </summary>
public string HostName { get; set; } = "localhost";
/// <summary>
......
......@@ -76,7 +76,6 @@ namespace DotNetCore.CAP.RabbitMQ
{
var factory = new ConnectionFactory
{
HostName = options.HostName,
UserName = options.UserName,
Port = options.Port,
Password = options.Password,
......@@ -86,6 +85,13 @@ namespace DotNetCore.CAP.RabbitMQ
SocketWriteTimeout = options.SocketWriteTimeout
};
if (options.HostName.Contains(","))
{
return () => factory.CreateConnection(
options.HostName.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries));
}
factory.HostName = options.HostName;
return () => factory.CreateConnection();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment