Skip to content

Commit edbdda1

Browse files
authored
Perform query to make sure cluster details are loaded (#606)
1 parent 81b724c commit edbdda1

File tree

6 files changed

+13
-13
lines changed

6 files changed

+13
-13
lines changed

src/NServiceBus.Storage.MongoDB.AcceptanceTests/NServiceBus.Storage.MongoDB.AcceptanceTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="8.0.0" />
1515
<PackageReference Include="NUnit" Version="3.14.0" />
1616
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
17-
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
17+
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
1818
</ItemGroup>
1919

2020
</Project>

src/NServiceBus.Storage.MongoDB.NoTx.AcceptanceTests/NServiceBus.Storage.MongoDB.NoTx.AcceptanceTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="8.0.0" />
1515
<PackageReference Include="NUnit" Version="3.14.0" />
1616
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
17-
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
17+
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
1818
</ItemGroup>
1919

2020
</Project>

src/NServiceBus.Storage.MongoDB.PersistenceTests/NServiceBus.Storage.MongoDB.PersistenceTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="NServiceBus.PersistenceTests.Sources" Version="8.0.0" />
1515
<PackageReference Include="NUnit" Version="3.14.0" />
1616
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
17-
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
17+
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
1818
</ItemGroup>
1919

2020
</Project>

src/NServiceBus.Storage.MongoDB.Tests/NServiceBus.Storage.MongoDB.Tests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<ItemGroup>
1313
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3" />
1414
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
15-
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
15+
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
1616
<PackageReference Include="NServiceBus" Version="8.0.3" />
1717
<PackageReference Include="NUnit" Version="3.14.0" />
1818
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />

src/NServiceBus.Storage.MongoDB.TransactionalSession.AcceptanceTests/NServiceBus.Storage.MongoDB.TransactionalSession.AcceptanceTests.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="NServiceBus.TransactionalSession" Version="2.0.2" />
1515
<PackageReference Include="NUnit" Version="3.14.0" />
1616
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
17-
<PackageReference Include="MongoDB.Driver" Version="2.19.1" />
17+
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
1818
</ItemGroup>
1919

2020
<ItemGroup>

src/NServiceBus.Storage.MongoDB/SynchronizedStorage/SynchronizedStorage.cs

+8-8
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,11 @@ protected override void Setup(FeatureConfigurationContext context)
2626

2727
try
2828
{
29-
client.GetDatabase(databaseName);
30-
}
31-
catch (ArgumentException ex)
32-
{
33-
throw new Exception($"The persistence database name '{databaseName}' is invalid. Configure a valid database name by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().DatabaseName(databaseName)'.", ex);
34-
}
29+
var database = client.GetDatabase(databaseName);
30+
31+
// perform a query to the server to make sure cluster details are loaded
32+
database.ListCollectionNames();
3533

36-
try
37-
{
3834
using (var session = client.StartSession())
3935
{
4036
if (useTransactions)
@@ -61,6 +57,10 @@ protected override void Setup(FeatureConfigurationContext context)
6157
}
6258
}
6359
}
60+
catch (ArgumentException ex)
61+
{
62+
throw new Exception($"The persistence database name '{databaseName}' is invalid. Configure a valid database name by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().DatabaseName(databaseName)'.", ex);
63+
}
6464
catch (NotSupportedException ex)
6565
{
6666
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);

0 commit comments

Comments
 (0)