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

Upgrade to NServiceBus.AmazonSQS 6.1.1 #246

Merged
merged 28 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
57ac737
Update TFM to net6.0
kentdr Mar 9, 2023
3c5e6f0
Update AmazonSQS transport
kentdr Mar 10, 2023
da5e08d
Singularize the TFM tag for projects
kentdr Mar 14, 2023
ba06dad
Set the SNS client in tests instead of null
kentdr Mar 14, 2023
c589cf1
Update TFM to add net7.0
kentdr Mar 24, 2023
b525699
Remove dotnet 3.1 from CI, add 6.0.x
kentdr Mar 24, 2023
4f5ea52
Change to discard operators
kentdr Mar 24, 2023
cce0497
Fix whitespace
kentdr Mar 24, 2023
ff37704
Change DispatchProperties paramter on TransportMessage
kentdr Mar 24, 2023
066d2ee
Remove generics from ServerlessTransport and ServerlessTransportInfra…
kentdr Mar 27, 2023
29ef1fd
Throw when cancellation token is cancelled.
kentdr Mar 27, 2023
1046f40
Remove preview info log
kentdr Mar 28, 2023
9118681
Update src/NServiceBus.AwsLambda.SQS/AwsLambdaSQSEndpointConfiguratio…
kentdr Mar 28, 2023
1035562
Use clock skew from SQS Client
kentdr Mar 29, 2023
511422d
Create delay queue during test startup
kentdr Mar 29, 2023
ed35323
Merge branch 'upgrade-to-v8' of https://github.com/Particular/NServic…
kentdr Mar 29, 2023
ef47da8
Remove TransactionMode property from ServerlessTransportInfrastructure
kentdr Mar 29, 2023
b3c8e42
Cache error handled task
kentdr Mar 29, 2023
9980f48
Move MakeServerless out of endpoint configuration
kentdr Mar 31, 2023
64194b4
Change catch block to use when condition
kentdr Mar 31, 2023
06800e7
Update TransportMessage ctor argument name to match sqs transport
kentdr Mar 31, 2023
c374a3e
Update src/NServiceBus.AwsLambda.SQS/AwsLambdaEndpoint.cs
kentdr Mar 31, 2023
1079d5d
Return in retry loop instead of setting flag
kentdr Mar 31, 2023
df4abae
Cosmetics
danielmarbach Apr 4, 2023
738fd45
Switch to System.Text.Json
danielmarbach Apr 4, 2023
fd29fec
Better integration with the transport and native integration
danielmarbach Apr 4, 2023
fe00e37
Properly testing native integration
danielmarbach Apr 4, 2023
4ce35dd
Remove condition
danielmarbach Apr 4, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
with:
dotnet-version: |
7.0.x
3.1.x
6.0.x
- name: Build
run: dotnet build src --configuration Release
- name: Upload packages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@
{
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Amazon.Lambda.SQSEvents;
using Amazon.Runtime;
using Amazon.S3;
using Amazon.S3.Model;
using Amazon.SimpleNotificationService;
using Amazon.SQS;
using Amazon.SQS.Model;
using NUnit.Framework;

[TestFixture]
class AwsLambdaSQSEndpointTestBase
{
protected const string DelayedDeliveryQueueSuffix = "-delay.fifo";
const int QueueDelayInSeconds = 900; // 15 * 60

protected string QueueName { get; set; }

protected string DelayQueueName { get; set; }

protected string ErrorQueueName { get; set; }

protected string QueueNamePrefix { get; set; }
Expand Down Expand Up @@ -51,6 +59,17 @@ public async Task Setup()
}
});
RegisterQueueNameToCleanup(ErrorQueueName);
DelayQueueName = $"{QueueName}{DelayedDeliveryQueueSuffix}";
_ = await sqsClient.CreateQueueAsync(new CreateQueueRequest(DelayQueueName)
{
Attributes = new Dictionary<string, string>
{
{ "FifoQueue", "true" },
{ QueueAttributeName.DelaySeconds, QueueDelayInSeconds.ToString(CultureInfo.InvariantCulture)}
}
});
RegisterQueueNameToCleanup(DelayQueueName);

s3Client = CreateS3Client();
KeyPrefix = QueueNamePrefix;
}
Expand Down Expand Up @@ -90,11 +109,13 @@ protected async Task<SQSEvent> GenerateAndReceiveSQSEvent<T>(int count) where T
{
var endpointConfiguration = new EndpointConfiguration($"{QueueNamePrefix}sender");
endpointConfiguration.SendOnly();
endpointConfiguration.UsePersistence<InMemoryPersistence>();
var transport = endpointConfiguration.UseTransport<SqsTransport>();
transport.ClientFactory(CreateSQSClient);
var s3 = transport.S3(BucketName, KeyPrefix);
s3.ClientFactory(CreateS3Client);

var transport = new SqsTransport(CreateSQSClient(), CreateSNSClient())
{
S3 = new S3Settings(BucketName, KeyPrefix, CreateS3Client())
};

endpointConfiguration.UseTransport(transport);

var endpointInstance = await Endpoint.Start(endpointConfiguration)
.ConfigureAwait(false);
Expand Down Expand Up @@ -133,6 +154,12 @@ public static IAmazonSQS CreateSQSClient()
return new AmazonSQSClient(credentials);
}

public static IAmazonSimpleNotificationService CreateSNSClient()
kentdr marked this conversation as resolved.
Show resolved Hide resolved
{
var credentials = new EnvironmentVariablesAWSCredentials();
return new AmazonSimpleNotificationServiceClient(credentials);
}

public static IAmazonS3 CreateS3Client()
{
var credentials = new EnvironmentVariablesAWSCredentials();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RootNamespace>NServiceBus.AwsLambda.Tests</RootNamespace>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;

class When_a_SQSEvent_with_large_payloads_is_processed : AwsLambdaSQSEndpointTestBase
Expand All @@ -15,16 +16,16 @@ public async Task The_handlers_should_be_invoked_and_process_successfully()

var endpoint = new AwsLambdaSQSEndpoint(ctx =>
{
var configuration = new AwsLambdaSQSEndpointConfiguration(QueueName);
var configuration = new AwsLambdaSQSEndpointConfiguration(QueueName, CreateSQSClient(), CreateSNSClient());
var transport = configuration.Transport;
transport.ClientFactory(CreateSQSClient);

var s3 = transport.S3(BucketName, KeyPrefix);
s3.ClientFactory(CreateS3Client);

transport.S3 = new S3Settings(BucketName, KeyPrefix, CreateS3Client());


var advanced = configuration.AdvancedConfiguration;
advanced.SendFailedMessagesTo(ErrorQueueName);
advanced.RegisterComponents(c => c.RegisterSingleton(typeof(TestContext), context));
advanced.RegisterComponents(c => c.AddSingleton(typeof(TestContext), context));
return configuration;
});

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
namespace NServiceBus.AwsLambda.Tests
{
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;

class When_a_handler_sends_a_message : AwsLambdaSQSEndpointTestBase
Expand All @@ -14,28 +15,28 @@ public async Task The_message_should_be_received()

var destinationEndpointName = $"{QueueNamePrefix}DestinationEndpoint";
RegisterQueueNameToCleanup(destinationEndpointName);
RegisterQueueNameToCleanup(destinationEndpointName + DelayedDeliveryQueueSuffix);

var destinationConfiguration = new EndpointConfiguration(destinationEndpointName);
destinationConfiguration.UsePersistence<InMemoryPersistence>();
var destinationTransport = destinationConfiguration.UseTransport<SqsTransport>();
destinationTransport.ClientFactory(CreateSQSClient);

var destinationTransport = new SqsTransport(CreateSQSClient(), CreateSNSClient());

destinationConfiguration.SendFailedMessagesTo(ErrorQueueName);
destinationConfiguration.EnableInstallers();
destinationConfiguration.RegisterComponents(c => c.RegisterSingleton(typeof(TestContext), context));
destinationConfiguration.RegisterComponents(c => c.AddSingleton(typeof(TestContext), context));
destinationConfiguration.UseTransport(destinationTransport);

var destinationEndpoint = await Endpoint.Start(destinationConfiguration);

var endpoint = new AwsLambdaSQSEndpoint(ctx =>
{
var configuration = new AwsLambdaSQSEndpointConfiguration(QueueName);
var transport = configuration.Transport;
transport.ClientFactory(CreateSQSClient);
var configuration = new AwsLambdaSQSEndpointConfiguration(QueueName, CreateSQSClient(), CreateSNSClient());

var routing = transport.Routing();
routing.RouteToEndpoint(typeof(SentMessage), destinationEndpointName);
configuration.RoutingSettings.RouteToEndpoint(typeof(SentMessage), destinationEndpointName);

var advanced = configuration.AdvancedConfiguration;
advanced.SendFailedMessagesTo(ErrorQueueName);
advanced.RegisterComponents(c => c.RegisterSingleton(typeof(TestContext), context));
advanced.RegisterComponents(c => c.AddSingleton(typeof(TestContext), context));
return configuration;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;

class When_a_message_handler_always_throws : AwsLambdaSQSEndpointTestBase
Expand All @@ -16,13 +17,11 @@ public async Task The_messages_should_forward_to_error_queue_by_default()

var endpoint = new AwsLambdaSQSEndpoint(ctx =>
{
var configuration = new AwsLambdaSQSEndpointConfiguration(QueueName);
var transport = configuration.Transport;
transport.ClientFactory(CreateSQSClient);
var configuration = new AwsLambdaSQSEndpointConfiguration(QueueName, CreateSQSClient(), CreateSNSClient());

var advanced = configuration.AdvancedConfiguration;
advanced.SendFailedMessagesTo(ErrorQueueName);
advanced.RegisterComponents(c => c.RegisterSingleton(typeof(TestContext), context));
advanced.RegisterComponents(c => c.AddSingleton(typeof(TestContext), context));
danielmarbach marked this conversation as resolved.
Show resolved Hide resolved
return configuration;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
{
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using NUnit.Framework;

class When_a_SQSEvent_is_processed : AwsLambdaSQSEndpointTestBase
Expand All @@ -15,13 +16,11 @@ public async Task The_handlers_should_be_invoked_and_process_successfully()

var endpoint = new AwsLambdaSQSEndpoint(ctx =>
{
var configuration = new AwsLambdaSQSEndpointConfiguration(QueueName);
var transport = configuration.Transport;
transport.ClientFactory(CreateSQSClient);
var configuration = new AwsLambdaSQSEndpointConfiguration(QueueName, CreateSQSClient(), CreateSNSClient());

var advanced = configuration.AdvancedConfiguration;
advanced.SendFailedMessagesTo(ErrorQueueName);
advanced.RegisterComponents(c => c.RegisterSingleton(typeof(TestContext), context));
advanced.RegisterComponents(c => c.AddSingleton(typeof(TestContext), context));
return configuration;
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ namespace NServiceBus
public class AwsLambdaSQSEndpointConfiguration
{
public AwsLambdaSQSEndpointConfiguration(string endpointName) { }
public AwsLambdaSQSEndpointConfiguration(string endpointName, Amazon.SQS.IAmazonSQS sqsClient, Amazon.SimpleNotificationService.IAmazonSimpleNotificationService snsClient) { }
public NServiceBus.EndpointConfiguration AdvancedConfiguration { get; }
public NServiceBus.TransportExtensions<NServiceBus.SqsTransport> Transport { get; }
public NServiceBus.RoutingSettings<NServiceBus.SqsTransport> RoutingSettings { get; }
public NServiceBus.SqsTransport Transport { get; }
public void DoNotSendMessagesToErrorQueue() { }
public NServiceBus.Serialization.SerializationExtensions<T> UseSerialization<T>()
where T : NServiceBus.Serialization.SerializationDefinition, new () { }
protected NServiceBus.TransportExtensions<TTransport> UseTransport<TTransport>()
where TTransport : NServiceBus.Transport.TransportDefinition, new () { }
}
public interface IAwsLambdaSQSEndpoint
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>netcoreapp3.1;net7.0</TargetFrameworks>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<RootNamespace>NServiceBus.AwsLambda.Tests</RootNamespace>
</PropertyGroup>
Expand Down