Method AdvanceAsync
- Namespace
- MailFathom.Application.Mail.Delivery
- Assembly
- MailFathom.Application.dll
AdvanceAsync(IPersistenceSession, OutgoingEmailLease, OutgoingEmailId, OutgoingEmailStage, int?, CancellationToken)
Moves the record to a terminal stage, recording the reply the server answered the transmission with.
Task AdvanceAsync(IPersistenceSession session, OutgoingEmailLease lease, OutgoingEmailId outgoingEmailId, OutgoingEmailStage stage, int? replyCode, CancellationToken cancellationToken)
Parameters
sessionIPersistenceSessionThe session the write joins.
leaseOutgoingEmailLeaseThe lease the attempt holds the record under.
outgoingEmailIdOutgoingEmailIdThe record to advance.
stageOutgoingEmailStageThe terminal stage the send has reached.
replyCodeint?The reply code the server answered the message with, or null when it answered none.
cancellationTokenCancellationTokenCancels the write.
Returns
- Task
A task that completes when the stage is written.
Remarks
A terminal stage is the only thing this writes, because every non-terminal stage is reached by a transition of its own.
Two of the three follow one stage only, which is the unknown window read from either end. Sent follows only TransmissionBegun, so no record claims a delivery it never recorded a transmission for; Cancelled follows only Recorded, so no record claims a withdrawal after bytes that may already have reached somebody. A send stopped mid-transmission therefore reaches none of the three: it stays at TransmissionBegun, stamped with OutgoingEmailOutcomeUnknown by the sweep this store runs before it claims, and nothing claims it again. Every terminal stage states something about what was received, and that is the one thing nobody can read there.
Exceptions
- ArgumentNullException
Thrown when
sessionorleaseis null.- OutgoingEmailLeaseLostException
Thrown when the record is held by a later attempt.
- ArgumentOutOfRangeException
Thrown when
stageis not a terminal stage, or whenreplyCodeis supplied and is not a three-digit reply code.- InvalidOperationException
Thrown when no record carries
outgoingEmailId, when it has already reached a terminal stage, or when the stage asked for does not follow the one the record reached.