Search code examples
c#amazon-sqsschedulingmasstransitdelayed-execution

Scheduled messages in MassTransit


I use masstransit 8 + amazon sqs/sns, the app is running in Windows Docker container.

I send scheduled messages, and the delay could be up to few hours, here is the code:

public Task Consume(ConsumeContext<RequestReceivedEvent> context)
{
    var uri = context.ReceiveContext.InputAddress;

    var scheduledTime = DateTime.UtcNow.AddHours(12);

    return context.ScheduleSend(uri, scheduledTime, new DelayedMessage());
}

However I have some questions regarding scheduled sending:

  1. What is the max delay interval to send message by schedule ?
  2. Where does the delay store - in memory of masstransit or in message/queue itself ?
  3. If the container is down and after a while it starts again - will masstransit still 'remember' the earlier created scheduled time for messages ?

Many thanks in advance!


Solution

    1. With SQS the maximum delay is 12 hours.
    2. The messages are stored in SQS
    3. SQS stores the messages, once the delay has elapsed, SQS will deliver the message when the service (container) is back up and running.