private int DeliverMailItem(MbxTransportMailItem mailItem, ulong sessionId) { int result = 0; TraceHelper.MessageProbeActivityId = mailItem.SystemProbeId; TraceHelper.StoreDriverDeliveryTracer.TracePass <string>(TraceHelper.MessageProbeActivityId, 0L, "Delivery: Processing started for MessageId {0}.", mailItem.InternetMessageId ?? "NULL"); TimeSpan?retryInterval; using (MailItemDeliver mailItemDeliver = new MailItemDeliver(mailItem, sessionId)) { try { StoreDriverDeliveryDiagnostics.HangDetector[sessionId] = mailItemDeliver; mailItemDeliver.DeliverToRecipients(); } finally { StoreDriverDeliveryDiagnostics.HangDetector.Remove(sessionId); } result = mailItemDeliver.DeliveredRecipients; retryInterval = mailItemDeliver.RetryInterval; } AckDetails ackDetails = new AckDetails(StoreDriverDelivery.localHostName); ackDetails.AddEventData("MailboxDatabaseName", mailItem.DatabaseName); mailItem.AckMailItem(AckStatus.Success, SmtpResponse.NoopOk, ackDetails, retryInterval, StoreDriverDelivery.GenerateSessionSourceContext(sessionId, mailItem.SessionStartTime)); TraceHelper.StoreDriverDeliveryTracer.TracePass <string>(TraceHelper.MessageProbeActivityId, 0L, "Delivery: Processing complete for MessageID {0}.", mailItem.InternetMessageId ?? "NULL"); return(result); }
public override void AckMailItem(AckStatus ackStatus, SmtpResponse smtpResponse, AckDetails details, TimeSpan?retryInterval, MessageTrackingSource source, string messageTrackingSourceContext, LatencyComponent deliveryComponent, string remoteMta, bool shadowed, string primaryServer, bool reportEndToEndLatencies) { if (this.recipientsPending != 0 && ackStatus == AckStatus.Success) { throw new InvalidOperationException("Cannot ack message successfully until all pending recipients have been acked"); } if (ackStatus == AckStatus.Pending) { this.recipientsPending = this.readyRecipients.Count; this.recipientEnumerator = this.mailItem.Recipients.GetEnumerator(); this.recipientEnumeratorAck = this.mailItem.Recipients.GetEnumerator(); this.result = null; } else { if (this.result == null) { this.result = new SmtpMailItemResult(); } this.result.MessageResponse = new AckStatusAndResponse(ackStatus, smtpResponse); this.mailItemSentForProcessing = true; } if (this.notificationHandler != null) { this.notificationHandler.AckMessage(ackStatus, smtpResponse); } }
public override void AckConnection(MessageTrackingSource messageTrackingSource, string messageTrackingSourceContext, AckStatus status, SmtpResponse smtpResponse, AckDetails details, TimeSpan?retryInterval, bool resubmitWithoutHighAvailablityRouting, SessionSetupFailureReason failureReason) { switch (status) { case AckStatus.Pending: case AckStatus.Skip: throw new InvalidOperationException("Invalid status"); case AckStatus.Success: case AckStatus.Retry: case AckStatus.Fail: case AckStatus.Resubmit: if (this.result == null) { this.result = new SmtpMailItemResult(); } this.result.ConnectionResponse = new AckStatusAndResponse(status, smtpResponse); if (details != null) { this.result.RemoteHostName = details.RemoteHostName; } if (this.notificationHandler != null) { this.notificationHandler.AckConnection(status, smtpResponse); } SmtpMailItemNextHopConnection.EndSmtpLatencyTracking(this.mailItem.LatencyTracker); if (this.autoResetEvent != null) { this.autoResetEvent.Set(); return; } break; case AckStatus.Expand: case AckStatus.Relay: case AckStatus.SuccessNoDsn: case AckStatus.Quarantine: break; default: return; } }
internal virtual void AckMailItem(AckStatus ackStatus, SmtpResponse smtpResponse, AckDetails ackDetails, TimeSpan?retryInterval, string messageTrackingSourceContext) { if (ackStatus == AckStatus.Retry && smtpResponse.SmtpResponseType != SmtpResponseType.TransientError) { smtpResponse = TransportMailItem.ReplaceFailWithRetryResponse(smtpResponse); } this.mailItem.Ack(ackStatus, smtpResponse, this.GetRecipients(), this.recipientResponses); this.FinalizeDeliveryLatencyTracking(LatencyComponent.StoreDriverDelivery); this.mailItemResponse = SmtpResponseGenerator.GenerateResponse(this.MessageLevelAction, this.Recipients, smtpResponse, retryInterval); foreach (MailRecipient mailRecipient in this.Recipients) { if (mailRecipient.ExtendedProperties.Contains("ExceptionAgentName")) { mailRecipient.ExtendedProperties.Remove("ExceptionAgentName"); } } }