Browse Source

support RabbitMQ cluster configuration.

master
Savorboard 6 years ago
parent
commit
0fdbf6ebf1
2 changed files with 11 additions and 2 deletions
  1. +4
    -1
      src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs
  2. +7
    -1
      src/DotNetCore.CAP.RabbitMQ/IConnectionChannelPool.Default.cs

+ 4
- 1
src/DotNetCore.CAP.RabbitMQ/CAP.RabbiMQOptions.cs View File

@@ -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>


+ 7
- 1
src/DotNetCore.CAP.RabbitMQ/IConnectionChannelPool.Default.cs View File

@@ -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();
}



Loading…
Cancel
Save