Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/Plugins/RabbitMQ/Factory/RabbitMqConnectionFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public IModel CreateChannel(string hostName, string username, string password, s
var key = $"{hostName}{username}{HashPassword(password)}{virtualHost}";

var connection = _connections.AddOrUpdate(key,
x => CreatConnection(hostName, username, password, virtualHost, key, useSSL, portNumber),
x => CreateConnection(hostName, username, password, virtualHost, key, useSSL, portNumber),
(updateKey, updateConnection) =>
{
// If connection to RMQ is lost and:
Expand All @@ -67,7 +67,7 @@ public IModel CreateChannel(string hostName, string username, string password, s
}
else
{
return CreatConnection(hostName, username, password, virtualHost, key, useSSL, portNumber);
return CreateConnection(hostName, username, password, virtualHost, key, useSSL, portNumber);
}
});

Expand Down Expand Up @@ -101,7 +101,7 @@ private void OnException(CallbackExceptionEventArgs args, IConnection value, str
}
}

private Lazy<IConnection> CreatConnection(string hostName, string username, string password, string virtualHost, string key, string useSSL, string portNumber)
private Lazy<IConnection> CreateConnection(string hostName, string username, string password, string virtualHost, string key, string useSSL, string portNumber)
{
if (!bool.TryParse(useSSL, out var sslEnabled))
{
Expand Down Expand Up @@ -129,6 +129,7 @@ private Lazy<IConnection> CreatConnection(string hostName, string username, stri
Ssl = sslOptions,
Port = port,
RequestedHeartbeat = TimeSpan.FromSeconds(10),
AutomaticRecoveryEnabled = true
}));

return new Lazy<IConnection>(connectionFactory.Value.CreateConnection);
Expand All @@ -139,7 +140,7 @@ private static object HashPassword(string password)
Guard.Against.NullOrWhiteSpace(password);
var sha256 = SHA256.Create();
var hash = sha256.ComputeHash(Encoding.UTF8.GetBytes(password));
return hash.Select(x => x.ToString("x2", CultureInfo.InvariantCulture));
return string.Join("", hash.Select(x => x.ToString("x2", CultureInfo.InvariantCulture)));
}

protected virtual void Dispose(bool disposing)
Expand Down
4 changes: 2 additions & 2 deletions src/Plugins/RabbitMQ/RabbitMQHealthCheck.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ public RabbitMQHealthCheck(
{
try
{
using var channel = _connectionFactory.CreateChannel(
var channel = _connectionFactory.CreateChannel(
_options[ConfigurationKeys.EndPoint],
_options[ConfigurationKeys.Username],
_options[ConfigurationKeys.Password],
_options[ConfigurationKeys.VirtualHost],
_options.ContainsKey(ConfigurationKeys.UseSSL) ? _options[ConfigurationKeys.UseSSL] : string.Empty,
_options.ContainsKey(ConfigurationKeys.Port) ? _options[ConfigurationKeys.Port] : string.Empty);
channel.Close();

return await Task.FromResult(HealthCheckResult.Healthy()).ConfigureAwait(false);
}
catch (Exception ex)
Expand Down