Skip to content

Commit

Permalink
Prepare for RTM (#2414)
Browse files Browse the repository at this point in the history
* Prepare for RTM

* Tweaks

* Don't use $(SolutionDir) in key path

* Remove Newtonsoft serializer

* React to JSON serializer being used instead of XML

* Formatting

* React to rebase changes

* Use collection initializers

* Adjustements after rebase

* Bump sdk

* Add debug logging to stop operations

* Add logging to start as well

* Add message processing logs

* Add more logging

* Stop purging

* Simplify

* Tweaks after rebase

* Exclude flaky test

* Cleanup

* Remove guard

* Add link to issue

* Tweaks

* Move error queue url fetching to the point where we need it to avoid lambda running into issues when the error queue doesn't exist

* Update packages

---------

Co-authored-by: Brandon Ording <[email protected]>
Co-authored-by: danielmarbach <[email protected]>
  • Loading branch information
3 people authored Feb 28, 2024
1 parent 43b404b commit 9fc53bb
Show file tree
Hide file tree
Showing 35 changed files with 162 additions and 228 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,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 Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,13 @@ jobs:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/[email protected]
uses: actions/[email protected]
with:
fetch-depth: 0
- name: Setup .NET SDK
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
8 changes: 4 additions & 4 deletions src/CommandLine/NServiceBus.Transports.SQS.CommandLine.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.SQS" Version="3.7.300.52" />
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="3.7.301" />
<PackageReference Include="AWSSDK.S3" Version="3.7.305.28" />
<PackageReference Include="AWSSDK.S3" Version="3.7.305.29" />
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="3.7.301.1" />
<PackageReference Include="AWSSDK.SQS" Version="3.7.300.53" />
<PackageReference Include="BitFaster.Caching" Version="2.4.1" />
<PackageReference Include="McMaster.Extensions.CommandLineUtils" Version="4.1.1" />
<PackageReference Include="Particular.Packaging" Version="4.0.0" PrivateAssets="All" />
<PackageReference Include="Particular.Packaging" Version="4.1.0" PrivateAssets="All" />
</ItemGroup>

</Project>
9 changes: 4 additions & 5 deletions src/CommandLine/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace NServiceBus.Transport.SQS.CommandLine
{
using System;
using System.Collections.Generic;
using McMaster.Extensions.CommandLineUtils;

// usage:
Expand Down Expand Up @@ -272,9 +271,9 @@ static int Main(string[] args)
{
var endpointName = nameArgument.Value;
var prefix = prefixOption.HasValue() ? prefixOption.Value() : DefaultConfigurationValues.QueueNamePrefix;
var eventTypes = eventTypeOption.HasValue() ? eventTypeOption.Values : new List<string>();
var eventTypes = eventTypeOption.HasValue() ? eventTypeOption.Values : [];

await CommandRunner.Run(accessKeyOption, secretOption, regionOption, (sqs, sns, s3) => Endpoint.SetPolicy(sqs, sns, prefix, endpointName, eventTypes, false, false, new List<string>()));
await CommandRunner.Run(accessKeyOption, secretOption, regionOption, (sqs, sns, s3) => Endpoint.SetPolicy(sqs, sns, prefix, endpointName, eventTypes, false, false, []));
});
});

Expand Down Expand Up @@ -315,8 +314,8 @@ static int Main(string[] args)
var addAccountCondition = accountWildcardOption.HasValue();
var addPrefixCondition = prefixWildcardOption.HasValue();
var prefix = prefixOption.HasValue() ? prefixOption.Value() : DefaultConfigurationValues.QueueNamePrefix;
var namespaceConditions = namespaceWildcardOption.HasValue() ? namespaceWildcardOption.Values : new List<string>();
var eventTypes = removeEventTypeOption.HasValue() ? removeEventTypeOption.Values : new List<string>();
var namespaceConditions = namespaceWildcardOption.HasValue() ? namespaceWildcardOption.Values : [];
var eventTypes = removeEventTypeOption.HasValue() ? removeEventTypeOption.Values : [];

await CommandRunner.Run(accessKeyOption, secretOption, regionOption, (sqs, sns, s3) => Endpoint.SetPolicy(sqs, sns, prefix, endpointName, eventTypes, addAccountCondition, addPrefixCondition, namespaceConditions));
});
Expand Down
1 change: 0 additions & 1 deletion src/CommandLineTests/CommandLineTests.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
namespace NServiceBus.Transport.SQS.CommandLine.Tests
{
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.SQS" Version="3.7.300.52" />
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="3.7.301" />
<PackageReference Include="AWSSDK.S3" Version="3.7.305.28" />
<PackageReference Include="BitFaster.Caching" Version="2.4.1" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NUnit" Version="3.14.0" />
Expand Down
2 changes: 1 addition & 1 deletion src/Custom.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<MinVerMinimumMajorMinor>7.0</MinVerMinimumMajorMinor>
<MinVerAutoIncrement>minor</MinVerAutoIncrement>
<MinVerAutoIncrement>minor</MinVerAutoIncrement>
</PropertyGroup>

</Project>
2 changes: 2 additions & 0 deletions src/NServiceBus.AmazonSQS.sln
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NServiceBus.Transports.SQS.
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{C1C8A6A2-0462-42F0-9FC4-5401EA3DE9AF}"
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
Global
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public virtual async Task<EndpointConfiguration> GetConfiguration(RunDescriptor

await builder.DefineTransport(TransportConfiguration, runDescriptor, endpointConfiguration).ConfigureAwait(false);

builder.UseSerialization<SystemJsonSerializer>();

await configurationBuilderCustomization(builder).ConfigureAwait(false);

// scan types at the end so that all types used by the configuration have been loaded into the AppDomain
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>$(SolutionDir)Test.snk</AssemblyOriginatorKeyFile>
<AssemblyOriginatorKeyFile>..\NServiceBusTests.snk</AssemblyOriginatorKeyFile>
<RootNamespace>NServiceBus.AcceptanceTests</RootNamespace>
</PropertyGroup>

Expand All @@ -12,16 +12,15 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="AWSSDK.SQS" Version="3.7.300.52" />
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="3.7.301" />
<PackageReference Include="AWSSDK.S3" Version="3.7.305.28" />
<PackageReference Include="AWSSDK.S3" Version="3.7.305.29" />
<PackageReference Include="AWSSDK.SimpleNotificationService" Version="3.7.301.1" />
<PackageReference Include="AWSSDK.SQS" Version="3.7.300.53" />
<PackageReference Include="BitFaster.Caching" Version="2.4.1" />
<PackageReference Include="GitHubActionsTestLogger" Version="2.3.3" />
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="9.0.0-alpha.9" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="NServiceBus.AcceptanceTests.Sources" Version="9.0.0" GeneratePathProperty="true" />
<PackageReference Include="NUnit" Version="3.14.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NServiceBus.Newtonsoft.Json" Version="4.0.0-alpha.1" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using AcceptanceTesting.Customization;
Expand Down Expand Up @@ -44,20 +44,10 @@ public static async Task ConsumePoisonQueue(Guid testRunId, string errorQueueAdd
}
}

public static async Task SendTo<TEndpoint, TMessage>(Dictionary<string, MessageAttributeValue> messageAttributeValues,
TMessage message)
where TMessage : IMessage
public static async Task SendTo<TEndpoint, TMessage>(Dictionary<string, MessageAttributeValue> messageAttributeValues, TMessage message) where TMessage : IMessage
{
using var sw = new Utf8StringWriter();
var serializer = new System.Xml.Serialization.XmlSerializer(typeof(TMessage));
serializer.Serialize(sw, message);

await SendTo<TEndpoint>(messageAttributeValues, sw.ToString());
}

sealed class Utf8StringWriter : StringWriter
{
public override Encoding Encoding => Encoding.UTF8;
var json = JsonSerializer.Serialize(message);
await SendTo<TEndpoint>(messageAttributeValues, json);
}

public static async Task SendTo<TEndpoint>(Dictionary<string, MessageAttributeValue> messageAttributeValues, string message, bool base64Encode = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@
{
using System;
using System.Collections.Generic;
using System.Threading;
using System.Text.Json;
using System.Threading.Tasks;
using System.Xml.Linq;
using AcceptanceTesting;
using Amazon.S3.Model;
using Amazon.SQS.Model;
using Configuration.AdvancedExtensibility;
using EndpointTemplates;
using global::Newtonsoft.Json;
using NUnit.Framework;
using Transport.SQS.Tests;

public class When_receiving_a_native_message_with_encoding : NServiceBusAcceptanceTest
{
static readonly string MessageToSend = new XDocument(new XElement("Message", new XElement("ThisIsTheMessage", "Hello!"))).ToString();
static readonly string MessageToSend = JsonSerializer.Serialize(new Message { ThisIsTheMessage = "Hello!" });

[Test]
public async Task Should_be_processed_when_messagetypefullname_present()
Expand All @@ -35,30 +32,6 @@ await NativeEndpoint.SendTo<Receiver>(new Dictionary<string, MessageAttributeVal
Assert.AreEqual("Hello!", context.MessageReceived);
}

[Test]
public async Task Should_be_processed_if_type_metadata_is_embedded()
{
var context = await Scenario.Define<Context>()
.WithEndpoint<Receiver>(c => c.CustomConfig(cfg =>
{
var serialization = cfg.UseSerialization<NewtonsoftJsonSerializer>();
serialization.Settings(new JsonSerializerSettings()
{
TypeNameHandling = TypeNameHandling.Auto
});
}).When(async _ =>
{
await NativeEndpoint.SendTo<Receiver>(new Dictionary<string, MessageAttributeValue>
{
{"SomeAttribute", new MessageAttributeValue {DataType = "String", StringValue = "SomeValue"}}
}, @$"{{ ""$type"": ""{typeof(Message).AssemblyQualifiedName}"", ""ThisIsTheMessage"": ""Hello!""}}");
}))
.Done(c => c.MessageReceived != null)
.Run();

Assert.AreEqual("Hello!", context.MessageReceived);
}

[Test]
public async Task Should_support_loading_body_from_s3()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using System.Xml.Linq;
using AcceptanceTesting;
using Amazon.S3.Model;
using Amazon.SQS.Model;
Expand All @@ -14,7 +13,7 @@

public class When_receiving_a_native_message_without_wrapper : NServiceBusAcceptanceTest
{
static readonly string MessageToSend = new XDocument(new XElement("NServiceBus.AcceptanceTests.NativeIntegration.NativeMessage", new XElement("ThisIsTheMessage", "Hello!"))).ToString();
static readonly string MessageToSend = JsonSerializer.Serialize(new NativeMessage { ThisIsTheMessage = "Hello!" });

[Test]
public async Task Should_be_processed_when_nsbheaders_present_with_messageid()
Expand Down Expand Up @@ -104,6 +103,8 @@ string GetHeaders(string s3Key = null, string messageId = null)
nsbHeaders.Add("NServiceBus.MessageId", messageId);
}

nsbHeaders.Add("NServiceBus.EnclosedMessageTypes", typeof(NativeMessage).FullName);

return JsonSerializer.Serialize(nsbHeaders);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ public MessageDrivenPubSubSubscriber() =>
{
c.DisableFeature<AutoSubscribe>();
c.GetSettings().Set("NServiceBus.AmazonSQS.DisableNativePubSub", true);
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig", new List<PublisherTableEntry>
{
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig",
[
new PublisherTableEntry(typeof(MyEvent), PublisherAddress.CreateFromEndpointName(Conventions.EndpointNamingConvention(typeof(Publisher))))
});
]);
},
metadata => metadata.RegisterPublisherFor<MyEvent>(typeof(Publisher)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 +187,10 @@ public MessageDrivenPubSubSubscriber() =>
{
c.DisableFeature<AutoSubscribe>();
c.GetSettings().Set("NServiceBus.AmazonSQS.DisableNativePubSub", true);
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig", new List<PublisherTableEntry>
{
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig",
[
new PublisherTableEntry(typeof(MyEvent), PublisherAddress.CreateFromEndpointName(Conventions.EndpointNamingConvention(typeof(Publisher))))
});
]);
},
metadata => metadata.RegisterPublisherFor<MyEvent>(typeof(Publisher)));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ public MessageDrivenPubSubSubscriber() =>
{
c.DisableFeature<AutoSubscribe>();
c.GetSettings().Set("NServiceBus.AmazonSQS.DisableNativePubSub", true);
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig", new List<PublisherTableEntry>
{
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig",
[
new PublisherTableEntry(typeof(MyEvent), PublisherAddress.CreateFromEndpointName(Conventions.EndpointNamingConvention(typeof(Publisher)))),
new PublisherTableEntry(typeof(MySecondEvent), PublisherAddress.CreateFromEndpointName(Conventions.EndpointNamingConvention(typeof(Publisher))))
});
]);
},
metadata =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,11 +217,10 @@ public MessageDrivenPubSubSubscriber() =>
c.DisableFeature<AutoSubscribe>();
c.GetSettings().Set("NServiceBus.AmazonSQS.DisableNativePubSub", true);
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig",
new List<PublisherTableEntry>
{
[
new PublisherTableEntry(typeof(MyEvent), PublisherAddress.CreateFromEndpointName(Conventions.EndpointNamingConvention(typeof(Publisher)))),
new PublisherTableEntry(typeof(MySecondEvent), PublisherAddress.CreateFromEndpointName(Conventions.EndpointNamingConvention(typeof(Publisher))))
});
]);
},
metadata =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public async Task Should_not_lose_any_events()
b.CustomConfig(c =>
{
c.GetSettings().Set("NServiceBus.AmazonSQS.DisableNativePubSub", true);
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig", new List<PublisherTableEntry>
{
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig",
[
new PublisherTableEntry(typeof(MyEvent), PublisherAddress.CreateFromEndpointName(PublisherEndpoint))
});
]);
});
b.When(async (session, ctx) =>
{
Expand Down Expand Up @@ -70,10 +70,10 @@ public async Task Should_not_lose_any_events()
b.CustomConfig(c =>
{
c.GetSettings().Set("NServiceBus.AmazonSQS.DisableNativePubSub", true);
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig", new List<PublisherTableEntry>
{
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig",
[
new PublisherTableEntry(typeof(MyEvent), PublisherAddress.CreateFromEndpointName(PublisherEndpoint))
});
]);
});
b.When(async (session, ctx) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ public async Task Should_not_lose_any_events()
b.CustomConfig(c =>
{
c.GetSettings().Set("NServiceBus.AmazonSQS.DisableNativePubSub", true);
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig", new List<PublisherTableEntry>
{
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig",
[
new PublisherTableEntry(typeof(MyEvent), PublisherAddress.CreateFromEndpointName(PublisherEndpoint))
});
]);
});
b.When(async (session, ctx) =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,10 @@ public Subscriber()
{
EndpointSetup(new CustomizedServer(false), (c, rd) =>
{
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig", new List<PublisherTableEntry>
{
c.GetSettings().GetOrCreate<Publishers>().AddOrReplacePublishers("LegacyConfig",
[
new PublisherTableEntry(typeof(MyEvent), PublisherAddress.CreateFromEndpointName(PublisherEndpoint))
});
]);
c.DisableFeature<AutoSubscribe>();
});
}
Expand Down
Loading

0 comments on commit 9fc53bb

Please sign in to comment.