Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #95

Closed
wants to merge 5 commits into from
Closed
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
4 changes: 2 additions & 2 deletions Rebus.RabbitMq/Config/RabbitMqOptionsBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -388,9 +388,9 @@ public string ClientProvidedName
set { _decoratedFactory.ClientProvidedName = value; }
}

public ConnectionFactoryClientNameDecorator(IConnectionFactory originalFacotry, string clientProvidedName)
public ConnectionFactoryClientNameDecorator(IConnectionFactory originalFactory, string clientProvidedName)
{
_decoratedFactory = originalFacotry;
_decoratedFactory = originalFactory;
_clientProvidedName = clientProvidedName;
}

Expand Down
30 changes: 17 additions & 13 deletions Rebus.RabbitMq/Internals/ConnectionManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Threading;
using RabbitMQ.Client;
using RabbitMQ.Client.Exceptions;
using Rebus.Logging;
using Rebus.RabbitMq;

Expand Down Expand Up @@ -65,7 +67,8 @@ public ConnectionManager(IList<ConnectionEndpoint> endpoints, string inputQueueA
Uri = uri, //Use the first URI in the list for ConnectionFactory to pick the AMQP credentials, VirtualHost (if any)
AutomaticRecoveryEnabled = true,
NetworkRecoveryInterval = TimeSpan.FromSeconds(30),
ClientProperties = CreateClientProperties(inputQueueAddress)
ClientProperties = CreateClientProperties(inputQueueAddress),
ClientProvidedName = $"{Assembly.GetEntryAssembly()?.GetName().Name ?? "rebus"}"
};

if (uri.TryGetCredentials(out var credentials))
Expand All @@ -92,7 +95,6 @@ public ConnectionManager(IList<ConnectionEndpoint> endpoints, string inputQueueA
}
})
.ToList();

}

public ConnectionManager(string connectionString, string inputQueueAddress, IRebusLoggerFactory rebusLoggerFactory, Func<IConnectionFactory, IConnectionFactory> customizer)
Expand All @@ -113,14 +115,13 @@ public ConnectionManager(string connectionString, string inputQueueAddress, IReb

var uriStrings = connectionString.Split(";,".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);

if (uriStrings.Length == 0)
{
throw new ArgumentException("Please remember to specify at least one connection string for a RabbitMQ server somewhere. You can also add multiple connection strings separated by ; or , which Rebus will use in failover scenarios");
}

if (uriStrings.Length > 1)
switch (uriStrings.Length)
{
_log.Info("RabbitMQ transport has {count} connection strings available", uriStrings.Length);
case 0:
throw new ArgumentException("Please remember to specify at least one connection string for a RabbitMQ server somewhere. You can also add multiple connection strings separated by ; or , which Rebus will use in failover scenarios");
case > 1:
_log.Info("RabbitMQ transport has {count} connection strings available", uriStrings.Length);
break;
}

var uri = new Uri(uriStrings.First());
Expand All @@ -130,7 +131,8 @@ public ConnectionManager(string connectionString, string inputQueueAddress, IReb
Uri = uri, //Use the first URI in the list for ConnectionFactory to pick the AMQP credentials (if any)
AutomaticRecoveryEnabled = true,
NetworkRecoveryInterval = TimeSpan.FromSeconds(30),
ClientProperties = CreateClientProperties(inputQueueAddress)
ClientProperties = CreateClientProperties(inputQueueAddress),
ClientProvidedName = $"{Assembly.GetEntryAssembly()?.GetName().Name ?? "rebus"}"
};

if (uri.TryGetCredentials(out var credentials))
Expand Down Expand Up @@ -163,7 +165,7 @@ public IConnection GetConnection()
{
var connection = _activeConnection;

if (connection != null && connection.IsOpen)
if (connection is { IsOpen: true })
{
return connection;
}
Expand All @@ -186,12 +188,14 @@ public IConnection GetConnection()
connection.Close();
connection.Dispose();
}
catch { }
catch (Exception exception) { _log.Warn("Existing connection exception: {message}", exception.Message); }
}

try
{
_activeConnection = _connectionFactory.CreateConnection(_amqpTcpEndpoints);
//TODO: not working with Amazon MQ
//_activeConnection = _connectionFactory.CreateConnection(_amqpTcpEndpoints);
_activeConnection = _connectionFactory.CreateConnection();

return _activeConnection;
}
Expand Down
5 changes: 3 additions & 2 deletions Rebus.RabbitMq/Rebus.RabbitMq.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@
<RepositoryType>git</RepositoryType>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>little_rebusbus2_copy-500x500.png</PackageIcon>
<AssemblyVersion>7.3.4.1</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="rebus" Version="[6, 7)" />
<PackageReference Include="RabbitMq.Client" Version="6.2.4" />
<PackageReference Include="rebus" Version="6.6.5" />
<PackageReference Include="RabbitMq.Client" Version="6.4.0" />
</ItemGroup>
<ItemGroup>
<None Include="..\artwork\little_rebusbus2_copy-500x500.png">
Expand Down