Table of Contents

Class RecurringSendOccurrenceHandler

Namespace
MailFathom.Application.Mail.Delivery.Scheduling
Assembly
MailFathom.Application.dll

Composes the message one occasion of a recurring send calls for, and writes it into the outbox.

public sealed class RecurringSendOccurrenceHandler : IJobHandler
Inheritance
RecurringSendOccurrenceHandler
Implements
Inherited Members

Remarks

The occasion produces an ordinary send and nothing more: an outgoing record with its own identity, its own attempts, its own failure, and its own ending. Nothing here transmits, and the delivery that follows is the one every other message gets — which is what makes one Monday's provider outage cost that Monday's message and no other's.

Which occasion this is running for is read from the schedule rather than carried in the payload, because a recurring dispatch repeats one piece of work and the occasion is the schedule's to decide. The most recent occasion at or before now is the one composed, so a run that started late still produces the message that was due rather than a message for a moment that has not come, and two runs reaching the same occasion compose one identity — which the outbox answers with the record the first one wrote.

One occurrence is in flight at a time, and this is where that is enforced rather than assumed. The message the last occasion produced is asked about first, and while it is still queued this occasion is answered instead of started: a weekly message whose provider has been unreachable all week must not put a second week's copy behind the first, and a message whose outcome nobody knows must not be followed by another until somebody has looked at it.

The message is due at the occasion rather than at the moment it was composed, which is what leaves the deployment's lateness bound holding for a repetition exactly as it holds for a message somebody scheduled by hand: an occasion reached long afterwards — because nothing was running, or because the queue was full — is delivered while it is still timely and stands where an operator can see it when it is not.

Running it twice with one payload is the same as running it once, which is what the queue asks of every handler.

Constructors

RecurringSendOccurrenceHandler(IRecurringSendStore, IOutgoingEmailStore, IEmailContentStore, IAuthoredEmailComposer, MailOutbox, OptimisticConcurrencyRetryPolicy, TimeProvider)

Initializes the handler from the declaration it reads and the outbox it writes into.

Properties

JobType

Gets the job type this handler runs, which is also the contract its payload arrives under.

Methods

RunAsync(IJobPayload, CancellationToken)

Runs the work the payload describes.