Skip to content

Commit

Permalink
Perform query to make sure cluster details are loaded (#606)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBoike authored Mar 18, 2024
1 parent 81b724c commit edbdda1
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="8.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>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="8.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>

</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="NServiceBus.PersistenceTests.Sources" Version="8.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>

</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="8.0.3" />
<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="2.0.2" />
<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 @@ -26,15 +26,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 @@ -61,6 +57,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 edbdda1

Please sign in to comment.