Skip to content

Commit 8b76237

Browse files
committed
Updates AWS SDK dependencies
Updates the AWS SDK dependencies to the latest versions. Refactors the SQS queue worker loop to use a cancellation token source for improved resource management and thread cleanup.
1 parent 0745fcb commit 8b76237

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/Foundatio.AWS/Foundatio.AWS.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
<PackageTags>$(PackageTags);Amazon;AWS;S3</PackageTags>
55
</PropertyGroup>
66
<ItemGroup>
7-
<PackageReference Include="AWSSDK.CloudWatch" Version="4.0.6.2" />
8-
<PackageReference Include="AWSSDK.S3" Version="4.0.16.1" />
9-
<PackageReference Include="AWSSDK.SQS" Version="4.0.2.9" />
7+
<PackageReference Include="AWSSDK.CloudWatch" Version="4.0.6.4" />
8+
<PackageReference Include="AWSSDK.S3" Version="4.0.17" />
9+
<PackageReference Include="AWSSDK.SQS" Version="4.0.2.11" />
1010

1111
<PackageReference Include="Foundatio" Version="12.0.1-preview.0.39" Condition="'$(ReferenceFoundatioSource)' == '' OR '$(ReferenceFoundatioSource)' == 'false'" />
1212
<ProjectReference Include="..\..\..\Foundatio\src\Foundatio\Foundatio.csproj" Condition="'$(ReferenceFoundatioSource)' == 'true'" />

src/Foundatio.AWS/Queues/SQSQueue.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -373,44 +373,44 @@ protected override void StartWorkingImpl(Func<IQueueEntry<T>, CancellationToken,
373373
if (handler == null)
374374
throw new ArgumentNullException(nameof(handler));
375375

376-
var linkedCancellationToken = GetLinkedDisposableCancellationTokenSource(cancellationToken);
376+
var linkedCancellationTokenSource = GetLinkedDisposableCancellationTokenSource(cancellationToken);
377377

378378
Task.Run(async () =>
379379
{
380380
_logger.LogTrace("WorkerLoop Start {QueueName}", _options.Name);
381381

382-
while (!linkedCancellationToken.IsCancellationRequested)
382+
while (!linkedCancellationTokenSource.IsCancellationRequested)
383383
{
384384
_logger.LogTrace("WorkerLoop Signaled {QueueName}", _options.Name);
385385

386386
IQueueEntry<T> entry = null;
387387
try
388388
{
389-
entry = await DequeueImplAsync(linkedCancellationToken.Token).AnyContext();
389+
entry = await DequeueImplAsync(linkedCancellationTokenSource.Token).AnyContext();
390390
}
391391
catch (OperationCanceledException) { }
392392

393-
if (linkedCancellationToken.IsCancellationRequested || entry == null)
393+
if (linkedCancellationTokenSource.IsCancellationRequested || entry == null)
394394
continue;
395395

396396
try
397397
{
398-
await handler(entry, linkedCancellationToken.Token).AnyContext();
399-
if (autoComplete && !entry.IsAbandoned && !entry.IsCompleted && !linkedCancellationToken.IsCancellationRequested)
398+
await handler(entry, linkedCancellationTokenSource.Token).AnyContext();
399+
if (autoComplete && !entry.IsAbandoned && !entry.IsCompleted && !linkedCancellationTokenSource.IsCancellationRequested)
400400
await entry.CompleteAsync().AnyContext();
401401
}
402402
catch (Exception ex)
403403
{
404404
Interlocked.Increment(ref _workerErrorCount);
405405
_logger.LogError(ex, "Worker error: {Message}", ex.Message);
406406

407-
if (!entry.IsAbandoned && !entry.IsCompleted && !linkedCancellationToken.IsCancellationRequested)
407+
if (!entry.IsAbandoned && !entry.IsCompleted && !linkedCancellationTokenSource.IsCancellationRequested)
408408
await entry.AbandonAsync().AnyContext();
409409
}
410410
}
411411

412-
_logger.LogTrace("Worker exiting: {QueueName} IsCancellationRequested={IsCancellationRequested}", _options.Name, linkedCancellationToken.IsCancellationRequested);
413-
}, linkedCancellationToken.Token).ContinueWith(_ => linkedCancellationToken.Dispose());
412+
_logger.LogTrace("Worker exiting: {QueueName} IsCancellationRequested={IsCancellationRequested}", _options.Name, linkedCancellationTokenSource.IsCancellationRequested);
413+
}, linkedCancellationTokenSource.Token).ContinueWith(_ => linkedCancellationTokenSource.Dispose());
414414
}
415415

416416
public override void Dispose()

0 commit comments

Comments
 (0)