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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
19 additions and
9 deletions
-
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() |
|
|
|
|