Commit 018035ce authored by Savorboard's avatar Savorboard

support RabbitMQ cluster configuration.

parent 273e7bf4
...@@ -37,7 +37,10 @@ namespace DotNetCore.CAP ...@@ -37,7 +37,10 @@ namespace DotNetCore.CAP
/// <summary> The topic exchange type. </summary> /// <summary> The topic exchange type. </summary>
public const string ExchangeType = "topic"; 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"; public string HostName { get; set; } = "localhost";
/// <summary> /// <summary>
......
...@@ -76,7 +76,6 @@ namespace DotNetCore.CAP.RabbitMQ ...@@ -76,7 +76,6 @@ namespace DotNetCore.CAP.RabbitMQ
{ {
var factory = new ConnectionFactory var factory = new ConnectionFactory
{ {
HostName = options.HostName,
UserName = options.UserName, UserName = options.UserName,
Port = options.Port, Port = options.Port,
Password = options.Password, Password = options.Password,
...@@ -86,6 +85,13 @@ namespace DotNetCore.CAP.RabbitMQ ...@@ -86,6 +85,13 @@ namespace DotNetCore.CAP.RabbitMQ
SocketWriteTimeout = options.SocketWriteTimeout SocketWriteTimeout = options.SocketWriteTimeout
}; };
if (options.HostName.Contains(","))
{
return () => factory.CreateConnection(
options.HostName.Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries));
}
factory.HostName = options.HostName;
return () => factory.CreateConnection(); 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