Skip to content

Commit 4552c13

Browse files
committed
AmazonSQS was possibly using the wrong cancellationToken making it impossible to shut down cleanly when consuming messages.
1 parent 8f7542e commit 4552c13

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

src/Transports/MassTransit.AmazonSqsTransport/AmazonSqsTransport/ConnectionContextFactory.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public ConnectionContextFactory(IAmazonSqsHostConfiguration hostConfiguration)
2222

2323
public IPipeContextAgent<ConnectionContext> CreateContext(ISupervisor supervisor)
2424
{
25-
Task<ConnectionContext> context = Task.Run(() => CreateConnection(supervisor), supervisor.Stopping);
25+
Task<ConnectionContext> context = Task.Run(() => CreateConnection(supervisor), supervisor.Stopped);
2626

2727
IPipeContextAgent<ConnectionContext> contextHandle = supervisor.AddContext(context);
2828

src/Transports/MassTransit.AmazonSqsTransport/AmazonSqsTransport/Middleware/AmazonSqsMessageReceiver.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected override async Task ActiveAndActualAgentsCompleted(StopContext context
5151

5252
async Task Consume()
5353
{
54-
await GetQueueAttributes(_context.CancellationToken).ConfigureAwait(false);
54+
await GetQueueAttributes(Stopping).ConfigureAwait(false);
5555

5656
using var algorithm = new RequestRateAlgorithm(new RequestRateAlgorithmOptions
5757
{
@@ -64,7 +64,7 @@ async Task Consume()
6464

6565
Task Handle(Message message, CancellationToken cancellationToken)
6666
{
67-
var lockContext = new AmazonSqsReceiveLockContext(_context.InputAddress, message, _receiveSettings, _client, cancellationToken);
67+
var lockContext = new AmazonSqsReceiveLockContext(_context.InputAddress, message, _receiveSettings, _client, Stopped);
6868

6969
return _receiveSettings.IsOrdered
7070
? _executorPool.Run(message, () => HandleMessage(message, lockContext), cancellationToken)

0 commit comments

Comments
 (0)