Skip to content

Commit bfb2cfa

Browse files
Merge branch 'dev'
2 parents 7cc3849 + 3de2f04 commit bfb2cfa

25 files changed

+171
-124
lines changed

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## Release 2025-07-14
2+
3+
### AWS.Messaging.Lambda (1.0.1)
4+
* Don't use .Any() on List<T>
5+
### AWS.Messaging (1.0.1)
6+
* Support scoped IAsyncDisposable services being disposed after message is processed
7+
* Minor threading and memory optimizations and cleanups
8+
19
## Release 2025-06-03
210

311
### AWS.Messaging.Telemetry.OpenTelemetry (0.23.0)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The **AWS Message Processing Framework for .NET** is an AWS-native framework tha
1010

1111
Add the `AWS.Messaging` NuGet package to your project:
1212
```
13-
dotnet add package AWS.Messaging --prerelease
13+
dotnet add package AWS.Messaging
1414
```
1515

1616
The framework integrates with .NET's [dependency injection (DI) service container](https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection). You can configure the framework during your application's startup by calling `AddAWSMessageBus` to add it to the DI container.

src/AWS.Messaging.Lambda/AWS.Messaging.Lambda.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<WarningsAsErrors>CA1727</WarningsAsErrors>
1717
<SignAssembly>true</SignAssembly>
1818
<AssemblyOriginatorKeyFile>..\..\public.snk</AssemblyOriginatorKeyFile>
19-
<Version>1.0.0</Version>
19+
<Version>1.0.1</Version>
2020
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2121
<EmbedUntrackedSources>true</EmbedUntrackedSources>
2222
<IncludeSymbols>true</IncludeSymbols>

src/AWS.Messaging.Lambda/DefaultLambdaMessaging.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public async Task ProcessLambdaEventAsync(SQSEvent sqsEvent, ILambdaContext cont
5151
{
5252
try
5353
{
54-
if (sqsEvent.Records?.Any() == false)
54+
if (sqsEvent.Records?.Count == 0)
5555
return;
5656

5757
_lambdaContextHolder.Context = context;
@@ -84,7 +84,7 @@ public async Task<SQSBatchResponse> ProcessLambdaEventWithBatchResponseAsync(SQS
8484
{
8585
try
8686
{
87-
if (sqsEvent.Records?.Any() == false)
87+
if (sqsEvent.Records?.Count == 0)
8888
return new SQSBatchResponse();
8989

9090
_lambdaContextHolder.Context = context;

src/AWS.Messaging.Lambda/Extensions/MessageBusBuilderExtensions.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
using Amazon.Lambda.Core;
54
using AWS.Messaging.Configuration;
65
using AWS.Messaging.Lambda;
76
using AWS.Messaging.Lambda.Services;
@@ -25,10 +24,7 @@ public static IMessageBusBuilder AddLambdaMessageProcessor(this IMessageBusBuild
2524
{
2625
var lambdaMessagingOptions = new LambdaMessagingOptions();
2726

28-
if (options != null)
29-
{
30-
options.Invoke(lambdaMessagingOptions);
31-
}
27+
options?.Invoke(lambdaMessagingOptions);
3228

3329
lambdaMessagingOptions.Validate();
3430

src/AWS.Messaging.Lambda/Services/DefaultLambdaMessageProcessor.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using AWS.Messaging.Services;
1010
using AWS.Messaging.SQS;
1111
using AWS.Messaging.Telemetry;
12-
using Microsoft.Extensions.Configuration;
1312
using Microsoft.Extensions.Logging;
1413

1514
namespace AWS.Messaging.Lambda.Services;
@@ -77,7 +76,7 @@ public DefaultLambdaMessageProcessor(
7776

7877
trace.AddMetadata(TelemetryKeys.QueueUrl, _configuration.SubscriberEndpoint);
7978

80-
if (sqsEvent is null || !sqsEvent.Records.Any())
79+
if (sqsEvent is null || sqsEvent.Records.Count == 0)
8180
{
8281
return _sqsBatchResponse;
8382
}

src/AWS.Messaging.Lambda/Services/LambdaMessageProcessorConfiguration.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33
using Amazon.Lambda.SQSEvents;
4-
using AWS.Messaging.Configuration;
54

65
namespace AWS.Messaging.Lambda.Services;
76

src/AWS.Messaging/AWS.Messaging.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
<NoWarn>CS1591</NoWarn>
1919
<SignAssembly>true</SignAssembly>
2020
<AssemblyOriginatorKeyFile>..\..\public.snk</AssemblyOriginatorKeyFile>
21-
<Version>1.0.0</Version>
21+
<Version>1.0.1</Version>
2222
<PublishRepositoryUrl>true</PublishRepositoryUrl>
2323
<EmbedUntrackedSources>true</EmbedUntrackedSources>
2424
<IncludeSymbols>true</IncludeSymbols>

src/AWS.Messaging/Configuration/AWSClientProvider.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
22
// SPDX-License-Identifier: Apache-2.0
33

4-
using System.Reflection;
54
using Amazon.Runtime;
65
using AWS.Messaging.Telemetry;
76

@@ -29,18 +28,18 @@ public AWSClientProvider(IServiceProvider serviceProvider)
2928
public T GetServiceClient<T>() where T : IAmazonService
3029
{
3130
var serviceClient = _serviceProvider.GetService(typeof(T)) ?? throw new FailedToFindAWSServiceClientException($"Failed to find AWS service client of type {typeof(T)}");
32-
if (serviceClient is AmazonServiceClient)
31+
if (serviceClient is AmazonServiceClient client)
3332
{
34-
((AmazonServiceClient)serviceClient).BeforeRequestEvent += AWSServiceClient_BeforeServiceRequest;
33+
client.BeforeRequestEvent += AWSServiceClient_BeforeServiceRequest;
3534
}
3635
return (T)serviceClient;
3736
}
3837

3938
internal static void AWSServiceClient_BeforeServiceRequest(object sender, RequestEventArgs e)
4039
{
41-
if (e is not WebServiceRequestEventArgs args || !args.Headers.ContainsKey(_userAgentHeader) || args.Headers[_userAgentHeader].Contains(_userAgentString))
40+
if (e is not WebServiceRequestEventArgs args || !args.Headers.TryGetValue(_userAgentHeader, out var value) || value.Contains(_userAgentString))
4241
return;
4342

44-
args.Headers[_userAgentHeader] = args.Headers[_userAgentHeader] + " " + _userAgentString;
43+
args.Headers[_userAgentHeader] = value + " " + _userAgentString;
4544
}
4645
}

src/AWS.Messaging/Configuration/MessageBusBuilder.cs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,7 @@ public IMessageBusBuilder AddSQSPoller(string queueUrl, Action<SQSMessagePollerO
115115
// Create the user-provided options class
116116
var sqsMessagePollerOptions = new SQSMessagePollerOptions();
117117

118-
if (options != null)
119-
{
120-
options.Invoke(sqsMessagePollerOptions);
121-
}
118+
options?.Invoke(sqsMessagePollerOptions);
122119

123120
sqsMessagePollerOptions.Validate();
124121

@@ -188,9 +185,9 @@ public IMessageBusBuilder LoadConfigurationFromSettings(IConfiguration configura
188185
{
189186
foreach (var sqsPublisher in settings.SQSPublishers)
190187
{
191-
var messageType = GetTypeFromAssemblies(callingAssembly, sqsPublisher.MessageType);
192-
if (messageType is null)
193-
throw new InvalidAppSettingsConfigurationException($"Unable to find the provided message type '{sqsPublisher.MessageType}'.");
188+
var messageType = GetTypeFromAssemblies(callingAssembly, sqsPublisher.MessageType)
189+
?? throw new InvalidAppSettingsConfigurationException($"Unable to find the provided message type '{sqsPublisher.MessageType}'.");
190+
194191
AddSQSPublisher(messageType, sqsPublisher.QueueUrl, sqsPublisher.MessageTypeIdentifier);
195192
}
196193
}
@@ -199,9 +196,9 @@ public IMessageBusBuilder LoadConfigurationFromSettings(IConfiguration configura
199196
{
200197
foreach (var snsPublisher in settings.SNSPublishers)
201198
{
202-
var messageType = GetTypeFromAssemblies(callingAssembly, snsPublisher.MessageType);
203-
if (messageType is null)
204-
throw new InvalidAppSettingsConfigurationException($"Unable to find the provided message type '{snsPublisher.MessageType}'.");
199+
var messageType = GetTypeFromAssemblies(callingAssembly, snsPublisher.MessageType)
200+
?? throw new InvalidAppSettingsConfigurationException($"Unable to find the provided message type '{snsPublisher.MessageType}'.");
201+
205202
AddSNSPublisher(messageType, snsPublisher.TopicUrl, snsPublisher.MessageTypeIdentifier);
206203
}
207204
}
@@ -210,9 +207,9 @@ public IMessageBusBuilder LoadConfigurationFromSettings(IConfiguration configura
210207
{
211208
foreach (var eventBridgePublisher in settings.EventBridgePublishers)
212209
{
213-
var messageType = GetTypeFromAssemblies(callingAssembly, eventBridgePublisher.MessageType);
214-
if (messageType is null)
215-
throw new InvalidAppSettingsConfigurationException($"Unable to find the provided message type '{eventBridgePublisher.MessageType}'.");
210+
var messageType = GetTypeFromAssemblies(callingAssembly, eventBridgePublisher.MessageType)
211+
?? throw new InvalidAppSettingsConfigurationException($"Unable to find the provided message type '{eventBridgePublisher.MessageType}'.");
212+
216213
AddEventBridgePublisher(messageType, eventBridgePublisher.EventBusName, eventBridgePublisher.MessageTypeIdentifier, eventBridgePublisher.Options);
217214
}
218215
}
@@ -221,17 +218,15 @@ public IMessageBusBuilder LoadConfigurationFromSettings(IConfiguration configura
221218
{
222219
foreach (var messageHandler in settings.MessageHandlers)
223220
{
224-
var messageType = GetTypeFromAssemblies(callingAssembly, messageHandler.MessageType);
225-
if (messageType is null)
226-
throw new InvalidAppSettingsConfigurationException($"Unable to find the provided message type '{messageHandler.MessageType}'.");
227-
var handlerType = GetTypeFromAssemblies(callingAssembly, messageHandler.HandlerType);
228-
if (handlerType is null)
229-
throw new InvalidAppSettingsConfigurationException($"Unable to find the provided message handler type '{messageHandler.HandlerType}'.");
221+
var messageType = GetTypeFromAssemblies(callingAssembly, messageHandler.MessageType)
222+
?? throw new InvalidAppSettingsConfigurationException($"Unable to find the provided message type '{messageHandler.MessageType}'.");
223+
var handlerType = GetTypeFromAssemblies(callingAssembly, messageHandler.HandlerType)
224+
?? throw new InvalidAppSettingsConfigurationException($"Unable to find the provided message handler type '{messageHandler.HandlerType}'.");
230225

231226
// This func is not Native AOT compatible but the method in general is marked
232227
// as not being Native AOT compatible due to loading dynamic types. So this
233228
// func not being Native AOT compatible is okay.
234-
var envelopeFactory = () =>
229+
MessageEnvelope envelopeFactory()
235230
{
236231
var messageEnvelopeType = typeof(MessageEnvelope<>).MakeGenericType(messageType);
237232
var envelope = Activator.CreateInstance(messageEnvelopeType);
@@ -241,7 +236,7 @@ public IMessageBusBuilder LoadConfigurationFromSettings(IConfiguration configura
241236

242237
}
243238
return (MessageEnvelope)envelope;
244-
};
239+
}
245240

246241
AddMessageHandler(handlerType, messageType, envelopeFactory, messageHandler.MessageTypeIdentifier);
247242
}

0 commit comments

Comments
 (0)