0

Using MassTransit with AWS SQS (simple queue service), we would like to implement a heartbeat, as advised in the AWS docs:

If you don't know how long it takes to process a message, create a heartbeat for your consumer process.

This requires changing the visibility of the message from code. AWS provides the ChangeMessageVisibility API for this. MassTransit does not seem to support this native AWS interface. Which is still no problem by itself, as it boils down to calling a HTTP endpoint (or using the SQSClient SDK, C# in our case).

For this to work one needs the RequestHandle. It is part of the raw response when the AWS CLI is used to receive the message (aws sqs receive-message --queue-url http://localhost:4566/queue/my-qeueu).

{
    "MessageId": "878eb3d8-2d1e-406f-87b6-24a3d493f5a9",
    "ReceiptHandle": "878eb3d8-2d1e-406f-87b6-24a3d493f5a9#464f467d-82a9-421f-bc10-cddd63630b7d",
    ...left out for brevity
}

Now the message ID is known at run time when inspecting the ConsumeContext<TMyMessage>.ReceiveContext.TransportHeaders['MessageId']. The RequestHandle, however, is nowhere to be found, or so it seems.

So how can one change the visibility timeout of the message in a AWS SQS queue, consumed by a MassTransit consumer?

1 Answer 1

1

As this is a duplicate of the same question asked on GitHub Discussions, the same answer would be that MassTransit automatically extends the visibility timeout until the consumer completes.

Up to the maximum of 12 hours that SQS allows.

Not the answer you're looking for? Browse other questions tagged or ask your own question.