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; connectionName ??= RabbitMqConnections.DefaultConnectionName;
return Connections.GetOrAdd( try
connectionName, () => new Lazy<IConnection>(() => {
{ var lazyConnection = Connections.GetOrAdd(
var connection = Options.Connections.GetOrDefault(connectionName); connectionName, () => new Lazy<IConnection>(() =>
var hostnames = connection.HostName.TrimEnd(';').Split(';'); {
// Handle Rabbit MQ Cluster. var connection = Options.Connections.GetOrDefault(connectionName);
return hostnames.Length == 1 ? connection.CreateConnection() : connection.CreateConnection(hostnames); var hostnames = connection.HostName.TrimEnd(';').Split(';');
// Handle Rabbit MQ Cluster.
return hostnames.Length == 1 ? connection.CreateConnection() : connection.CreateConnection(hostnames);
})
);
}) return lazyConnection.Value;
).Value; }
catch (Exception)
{
Connections.TryRemove(connectionName, out _);
throw;
}
} }
public void Dispose() public void Dispose()

Loading…
Cancel
Save