Skip to content

Commit

Permalink
Perform query to make sure cluster details are loaded (#607)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBoike authored Mar 18, 2024
1 parent 4e53c88 commit 04be6e3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="7.8.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="7.8.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<ItemGroup>
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
<PackageReference Include="NServiceBus" Version="7.8.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="NServiceBus.TransactionalSession" Version="1.0.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,11 @@ protected override void Setup(FeatureConfigurationContext context)

try
{
client.GetDatabase(databaseName);
}
catch (ArgumentException ex)
{
throw new Exception($"The persistence database name '{databaseName}' is invalid. Configure a valid database name by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().DatabaseName(databaseName)'.", ex);
}
var database = client.GetDatabase(databaseName);

// perform a query to the server to make sure cluster details are loaded
database.ListCollectionNames();

try
{
using (var session = client.StartSession())
{
if (useTransactions)
Expand All @@ -58,6 +54,10 @@ protected override void Setup(FeatureConfigurationContext context)
}
}
}
catch (ArgumentException ex)
{
throw new Exception($"The persistence database name '{databaseName}' is invalid. Configure a valid database name by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().DatabaseName(databaseName)'.", ex);
}
catch (NotSupportedException ex)
{
throw new Exception("Sessions are not supported by the MongoDB server. The NServiceBus.Storage.MongoDB persistence requires MongoDB server version 3.6 or greater.", ex);
Expand Down

0 comments on commit 04be6e3

Please sign in to comment.