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

Prepare RTM #595

Merged
merged 18 commits into from
Mar 14, 2024
Merged
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
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ jobs:
uses: actions/[email protected]
with:
dotnet-version: 8.0.x
dotnet-quality: 'preview'
- name: Build
run: dotnet build src --configuration Release
- name: Upload packages
Expand All @@ -43,7 +42,7 @@ jobs:
path: nugets/
retention-days: 7
- name: Setup MongoDB Server
uses: Particular/setup-mongodb-action@v1.3.1
uses: Particular/setup-mongodb-action@v1.4.0
with:
connection-string-name: NServiceBusStorageMongoDB_ConnectionString
mongodb-port: 27018
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ jobs:
uses: actions/[email protected]
with:
dotnet-version: 8.0.x
dotnet-quality: 'preview'
- name: Build
run: dotnet build src --configuration Release
- name: Sign NuGet packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<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.2" />
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="9.0.0-alpha.6" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="9.0.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<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.2" />
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="9.0.0-alpha.6" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="9.0.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
<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.2" />
<PackageReference Include="NServiceBus.PersistenceTests.Sources" Version="9.0.0-alpha.6" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
<PackageReference Include="NServiceBus.PersistenceTests.Sources" Version="9.0.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
<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.2" />
<PackageReference Include="NServiceBus" Version="9.0.0-alpha.6" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
<PackageReference Include="NServiceBus" Version="9.0.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="Particular.Approvals" Version="1.0.0" />
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,39 @@

public class TransactionSessionDefaultServer : IEndpointSetupTemplate
{
public virtual async Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointConfiguration,
public virtual async Task<EndpointConfiguration> GetConfiguration(RunDescriptor runDescriptor, EndpointCustomizationConfiguration endpointCustomizations,
Func<EndpointConfiguration, Task> configurationBuilderCustomization)
{
var builder = new EndpointConfiguration(endpointConfiguration.EndpointName);
builder.EnableInstallers();
var endpointConfiguration = new EndpointConfiguration(endpointCustomizations.EndpointName);

builder.Recoverability()
endpointConfiguration.EnableInstallers();
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
endpointConfiguration.Recoverability()
.Delayed(delayed => delayed.NumberOfRetries(0))
.Immediate(immediate => immediate.NumberOfRetries(0));
builder.SendFailedMessagesTo("error");
endpointConfiguration.SendFailedMessagesTo("error");

var storageDir = Path.Combine(Path.GetTempPath(), "learn", TestContext.CurrentContext.Test.ID);

builder.UseTransport(new AcceptanceTestingTransport
endpointConfiguration.UseTransport(new AcceptanceTestingTransport
{
StorageLocation = storageDir
});

var mongoSettings = builder.UsePersistence<MongoPersistence>();
var mongoSettings = endpointConfiguration.UsePersistence<MongoPersistence>();
mongoSettings.EnableTransactionalSession();
mongoSettings.MongoClient(SetupFixture.MongoClient);
mongoSettings.DatabaseName(SetupFixture.DatabaseName);
mongoSettings.UseTransactions(true);

builder.RegisterStartupTask(sp => new CaptureServiceProviderStartupTask(sp, runDescriptor.ScenarioContext));
endpointConfiguration.RegisterStartupTask(sp => new CaptureServiceProviderStartupTask(sp, runDescriptor.ScenarioContext));

await configurationBuilderCustomization(builder).ConfigureAwait(false);
await configurationBuilderCustomization(endpointConfiguration).ConfigureAwait(false);

// scan types at the end so that all types used by the configuration have been loaded into the AppDomain
builder.TypesToIncludeInScan(endpointConfiguration.GetTypesScopedByTestClass());
endpointConfiguration.TypesToIncludeInScan(endpointCustomizations.GetTypesScopedByTestClass());

return builder;
return endpointConfiguration;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
<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.2" />
<PackageReference Include="NServiceBus.AcceptanceTesting" Version="9.0.0-alpha.6" />
<PackageReference Include="NServiceBus.TransactionalSession" Version="3.0.0-alpha.1" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
<PackageReference Include="NServiceBus.AcceptanceTesting" Version="9.0.0" />
<PackageReference Include="NServiceBus.TransactionalSession" Version="3.0.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="2.19.2" />
<PackageReference Include="NServiceBus" Version="9.0.0-alpha.6" />
<PackageReference Include="NServiceBus.TransactionalSession" Version="3.0.0-alpha.1" />
<PackageReference Include="MongoDB.Driver" Version="2.24.0" />
<PackageReference Include="NServiceBus" Version="9.0.0" />
<PackageReference Include="NServiceBus.TransactionalSession" Version="3.0.0" />
<PackageReference Include="Particular.Approvals" Version="1.0.0" />
<PackageReference Include="PublicApiGenerator" Version="11.1.0" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="NServiceBus.TransactionalSession" Version="3.0.0-alpha.1" />
<PackageReference Include="NServiceBus.TransactionalSession" Version="[3.0.0, 4.0.0)" />
<PackageReference Include="Particular.Packaging" Version="4.1.0" PrivateAssets="All" />
</ItemGroup>

</Project>
</Project>
4 changes: 3 additions & 1 deletion src/NServiceBus.Storage.MongoDB.sln
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.Storage.MongoDB
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{204B96DD-7CDD-498E-B527-2CA09B17AD6D}"
ProjectSection(SolutionItems) = preProject
..\.github\workflows\ci.yml = ..\.github\workflows\ci.yml
Custom.Build.props = Custom.Build.props
..\.github\workflows\release.yml = ..\.github\workflows\release.yml
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.Storage.MongoDB.AcceptanceTests", "NServiceBus.Storage.MongoDB.AcceptanceTests\NServiceBus.Storage.MongoDB.AcceptanceTests.csproj", "{6BCA8AC9-E4BC-4920-BA3F-C218708B8A6B}"
Expand All @@ -22,7 +24,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.Storage.MongoDB
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.Storage.MongoDB.TransactionalSession.AcceptanceTests", "NServiceBus.Storage.MongoDB.TransactionalSession.AcceptanceTests\NServiceBus.Storage.MongoDB.TransactionalSession.AcceptanceTests.csproj", "{704337C7-74B5-435A-88C7-AC0E10EA7795}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NServiceBus.Storage.MongoDB.TransactionalSession.Tests", "NServiceBus.Storage.MongoDB.TransactionalSession.Tests\NServiceBus.Storage.MongoDB.TransactionalSession.Tests.csproj", "{C9FA6374-432B-4E58-AC5C-7C86FEAA9256}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.Storage.MongoDB.TransactionalSession.Tests", "NServiceBus.Storage.MongoDB.TransactionalSession.Tests\NServiceBus.Storage.MongoDB.TransactionalSession.Tests.csproj", "{C9FA6374-432B-4E58-AC5C-7C86FEAA9256}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ internal CompatibilitySettings(SettingsHolder settingsHolder) : base(settingsHol
/// </summary>
public CompatibilitySettings VersionElementName(string versionElementName)
{
Guard.AgainstNullAndEmpty(nameof(versionElementName), versionElementName);
ArgumentException.ThrowIfNullOrWhiteSpace(versionElementName);

this.GetSettings().Set(SettingsKeys.VersionElementName, versionElementName);
return this;
Expand All @@ -30,7 +30,7 @@ public CompatibilitySettings VersionElementName(string versionElementName)
/// </summary>
public CompatibilitySettings CollectionNamingConvention(Func<Type, string> collectionNamingConvention)
{
Guard.AgainstNull(nameof(collectionNamingConvention), collectionNamingConvention);
ArgumentNullException.ThrowIfNull(collectionNamingConvention);

this.GetSettings().Set(SettingsKeys.CollectionNamingConvention, collectionNamingConvention);
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public static class MongoSettingsExtensions
/// </summary>
public static PersistenceExtensions<MongoPersistence> MongoClient(this PersistenceExtensions<MongoPersistence> persistenceExtensions, IMongoClient mongoClient)
{
Guard.AgainstNull(nameof(persistenceExtensions), persistenceExtensions);
Guard.AgainstNull(nameof(mongoClient), mongoClient);
ArgumentNullException.ThrowIfNull(persistenceExtensions);
ArgumentNullException.ThrowIfNull(mongoClient);

persistenceExtensions.GetSettings().Set(SettingsKeys.MongoClient, () => mongoClient);
return persistenceExtensions;
Expand All @@ -27,8 +27,8 @@ public static PersistenceExtensions<MongoPersistence> MongoClient(this Persisten
/// </summary>
public static PersistenceExtensions<MongoPersistence> DatabaseName(this PersistenceExtensions<MongoPersistence> persistenceExtensions, string databaseName)
{
Guard.AgainstNull(nameof(persistenceExtensions), persistenceExtensions);
Guard.AgainstNullAndEmpty(nameof(databaseName), databaseName);
ArgumentNullException.ThrowIfNull(persistenceExtensions);
ArgumentException.ThrowIfNullOrWhiteSpace(databaseName);

persistenceExtensions.GetSettings().Set(SettingsKeys.DatabaseName, databaseName);
return persistenceExtensions;
Expand All @@ -39,7 +39,7 @@ public static PersistenceExtensions<MongoPersistence> DatabaseName(this Persiste
/// </summary>
public static PersistenceExtensions<MongoPersistence> UseTransactions(this PersistenceExtensions<MongoPersistence> persistenceExtensions, bool useTransactions)
{
Guard.AgainstNull(nameof(persistenceExtensions), persistenceExtensions);
ArgumentNullException.ThrowIfNull(persistenceExtensions);

persistenceExtensions.GetSettings().Set(SettingsKeys.UseTransactions, useTransactions);
return persistenceExtensions;
Expand All @@ -50,8 +50,8 @@ public static PersistenceExtensions<MongoPersistence> UseTransactions(this Persi
/// </summary>
public static PersistenceExtensions<MongoPersistence> TimeToKeepOutboxDeduplicationData(this PersistenceExtensions<MongoPersistence> persistenceExtensions, TimeSpan timeToKeepOutboxDeduplicationData)
{
Guard.AgainstNull(nameof(persistenceExtensions), persistenceExtensions);
Guard.AgainstNegativeAndZero(nameof(timeToKeepOutboxDeduplicationData), timeToKeepOutboxDeduplicationData);
ArgumentNullException.ThrowIfNull(persistenceExtensions);
ArgumentOutOfRangeException.ThrowIfLessThanOrEqual(timeToKeepOutboxDeduplicationData, TimeSpan.Zero);

var seconds = Math.Ceiling(timeToKeepOutboxDeduplicationData.TotalSeconds);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="MongoDB.Driver" Version="[2.19.2, 3.0.0)" />
<PackageReference Include="NServiceBus" Version="9.0.0-alpha.6" />
<PackageReference Include="MongoDB.Driver" Version="[2.24.0, 3.0.0)" />
<PackageReference Include="NServiceBus" Version="[9.0.0, 10.0.0)" />
<PackageReference Include="Particular.Packaging" Version="4.1.0" PrivateAssets="All" />
</ItemGroup>

Expand All @@ -15,4 +15,4 @@
<InternalsVisibleTo Include="NServiceBus.Storage.MongoDB.PersistenceTests" />
</ItemGroup>

</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,40 @@ 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);

try
{
using (var session = client.StartSession())
// perform a query to the server to make sure cluster details are loaded
database.ListCollectionNames();

using var session = client.StartSession();

if (useTransactions)
{
if (useTransactions)
{
var clusterType = client.Cluster.Description.Type;
var clusterType = client.Cluster.Description.Type;

//HINT: cluster configuration check is needed as the built-in checks, executed during "StartTransaction() call,
// do not detect if the cluster configuration is a supported one. Only the version ranges are validated.
// Without this check, exceptions will be thrown during message processing.
if (clusterType is not ClusterType.ReplicaSet and not ClusterType.Sharded)
{
throw new Exception($"Transactions are only supported on replica sets or sharded clusters. Disable support for transactions by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().UseTransactions(false)'.");
}
//HINT: cluster configuration check is needed as the built-in checks, executed during "StartTransaction() call,
// do not detect if the cluster configuration is a supported one. Only the version ranges are validated.
// Without this check, exceptions will be thrown during message processing.
if (clusterType is not ClusterType.ReplicaSet and not ClusterType.Sharded)
{
throw new Exception($"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)'.");
}

try
{
session.StartTransaction();
session.AbortTransaction();
}
catch (NotSupportedException ex)
{
throw new Exception($"Transactions are not supported by the MongoDB server. Disable support for transactions by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().UseTransactions(false)'.", ex);
}
try
{
session.StartTransaction();
session.AbortTransaction();
}
catch (NotSupportedException ex)
{
throw new Exception($"Transactions are not supported by the MongoDB server. Disable support for transactions by calling 'EndpointConfiguration.UsePersistence<{nameof(MongoPersistence)}>().UseTransactions(false)'.", ex);
}
}
}
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static IClientSessionHandle GetClientSession(this ISynchronizedStorageSes
/// </summary>
public static IMongoSynchronizedStorageSession MongoPersistenceSession(this ISynchronizedStorageSession session)
{
Guard.AgainstNull(nameof(session), session);
ArgumentNullException.ThrowIfNull(session);

if (session is IMongoSynchronizedStorageSession mongoSession)
{
Expand Down
Loading