Browse Source

Merge pull request #9011 from abpframework/auto-merge/rel-4-3/383

Merge branch dev with rel-4.3
pull/9021/head
maliming 5 years ago
committed by GitHub
parent
commit
11c94b5e1d
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 28
      framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/ConnectionPool.cs

28
framework/src/Volo.Abp.RabbitMQ/Volo/Abp/RabbitMQ/ConnectionPool.cs

@ -25,16 +25,26 @@ namespace Volo.Abp.RabbitMQ
{
connectionName ??= RabbitMqConnections.DefaultConnectionName;
return Connections.GetOrAdd(
connectionName, () => new Lazy<IConnection>(() =>
{
var connection = Options.Connections.GetOrDefault(connectionName);
var hostnames = connection.HostName.TrimEnd(';').Split(';');
// Handle Rabbit MQ Cluster.
return hostnames.Length == 1 ? connection.CreateConnection() : connection.CreateConnection(hostnames);
try
{
var lazyConnection = Connections.GetOrAdd(
connectionName, () => new Lazy<IConnection>(() =>
{
var connection = Options.Connections.GetOrDefault(connectionName);
var hostnames = connection.HostName.TrimEnd(';').Split(';');
// Handle Rabbit MQ Cluster.
return hostnames.Length == 1 ? connection.CreateConnection() : connection.CreateConnection(hostnames);
})
);
})
).Value;
return lazyConnection.Value;
}
catch (Exception)
{
Connections.TryRemove(connectionName, out _);
throw;
}
}
public void Dispose()

Loading…
Cancel
Save