You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Prepare RTM
* Improve ex message
* Try 7.2.1
* 7.0.5
* Rollback to 2.19.2
* Try MongoDB.Driver 2.23.0
* Try 2.22.0
* Try 2.20.0
* Go back to 2.19.2
* Do a fake list databases to ensure that cluster info is fetched
* Prepare RTM
* Cleanup
* Revert to 2.19.2
* Try list collections instead
* Comment
* Try unstable version
* Stable version
* Tweaks
---------
Co-authored-by: Daniel Marbach <[email protected]>
Co-authored-by: Brandon Ording <[email protected]>
Copy file name to clipboardExpand all lines: src/NServiceBus.Storage.MongoDB.NoTx.AcceptanceTests/NServiceBus.Storage.MongoDB.NoTx.AcceptanceTests.csproj
Copy file name to clipboardExpand all lines: src/NServiceBus.Storage.MongoDB.TransactionalSession.AcceptanceTests/Infrastructure/TransactionSessionDefaultServer.cs
Copy file name to clipboardExpand all lines: src/NServiceBus.Storage.MongoDB.TransactionalSession.AcceptanceTests/NServiceBus.Storage.MongoDB.TransactionalSession.AcceptanceTests.csproj
Copy file name to clipboardExpand all lines: src/NServiceBus.Storage.MongoDB.TransactionalSession.Tests/NServiceBus.Storage.MongoDB.TransactionalSession.Tests.csproj
Copy file name to clipboardExpand all lines: src/NServiceBus.Storage.MongoDB.TransactionalSession/NServiceBus.Storage.MongoDB.TransactionalSession.csproj
thrownewException($"The persistence database name '{databaseName}' is invalid. Configure a valid database name by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().DatabaseName(databaseName)'.",ex);
34
-
}
29
+
vardatabase=client.GetDatabase(databaseName);
35
30
36
-
try
37
-
{
38
-
using(varsession=client.StartSession())
31
+
// perform a query to the server to make sure cluster details are loaded
32
+
database.ListCollectionNames();
33
+
34
+
usingvarsession=client.StartSession();
35
+
36
+
if(useTransactions)
39
37
{
40
-
if(useTransactions)
41
-
{
42
-
varclusterType=client.Cluster.Description.Type;
38
+
varclusterType=client.Cluster.Description.Type;
43
39
44
-
//HINT: cluster configuration check is needed as the built-in checks, executed during "StartTransaction() call,
45
-
// do not detect if the cluster configuration is a supported one. Only the version ranges are validated.
46
-
// Without this check, exceptions will be thrown during message processing.
47
-
if(clusterTypeis not ClusterType.ReplicaSet and not ClusterType.Sharded)
48
-
{
49
-
thrownewException($"Transactions are only supported on replica sets or sharded clusters. Disable support for transactions by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().UseTransactions(false)'.");
50
-
}
40
+
//HINT: cluster configuration check is needed as the built-in checks, executed during "StartTransaction() call,
41
+
// do not detect if the cluster configuration is a supported one. Only the version ranges are validated.
42
+
// Without this check, exceptions will be thrown during message processing.
43
+
if(clusterTypeis not ClusterType.ReplicaSet and not ClusterType.Sharded)
44
+
{
45
+
thrownewException($"The cluster type in use is {clusterType}, but transactions are only supported on replica sets or sharded clusters. Disable support for transactions by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().UseTransactions(false)'.");
46
+
}
51
47
52
-
try
53
-
{
54
-
session.StartTransaction();
55
-
session.AbortTransaction();
56
-
}
57
-
catch(NotSupportedExceptionex)
58
-
{
59
-
thrownewException($"Transactions are not supported by the MongoDB server. Disable support for transactions by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().UseTransactions(false)'.",ex);
60
-
}
48
+
try
49
+
{
50
+
session.StartTransaction();
51
+
session.AbortTransaction();
52
+
}
53
+
catch(NotSupportedExceptionex)
54
+
{
55
+
thrownewException($"Transactions are not supported by the MongoDB server. Disable support for transactions by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().UseTransactions(false)'.",ex);
61
56
}
62
57
}
63
58
}
59
+
catch(ArgumentExceptionex)
60
+
{
61
+
thrownewException($"The persistence database name '{databaseName}' is invalid. Configure a valid database name by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().DatabaseName(databaseName)'.",ex);
62
+
}
64
63
catch(NotSupportedExceptionex)
65
64
{
66
65
thrownewException("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