public void TriggerAck(int id, AckStatus ackStatus) { if (_acks.TryRemove(id, out var ack)) { ack.Tcs.TrySetResult(ackStatus); } }
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 AckRecipient(AckStatus ackStatus, SmtpResponse smtpResponse) { TraceHelper.SmtpSendTracer.TracePass <string, string>(TraceHelper.MessageProbeActivityId, (long)this.GetHashCode(), "InboundProxyNextHopConnection.AckRecipient. Ackstatus = {0}. SmtpResponse = {1}", ackStatus.ToString(), smtpResponse.ToString()); if (!this.recipientEnumeratorAck.MoveNext() || this.recipientsPending <= 0) { throw new InvalidOperationException("AckRecipient called but no recipients left to ack"); } this.recipientsPending--; MailRecipient recipient = this.recipientEnumeratorAck.Current; switch (ackStatus) { case AckStatus.Pending: case AckStatus.Success: case AckStatus.Retry: case AckStatus.Fail: if (this.result == null) { this.result = new SmtpMailItemResult(); } if (this.result.RecipientResponses == null) { this.result.RecipientResponses = new Dictionary <MailRecipient, AckStatusAndResponse>(); } this.result.RecipientResponses.Add(recipient, new AckStatusAndResponse(ackStatus, smtpResponse)); if (this.notificationHandler != null) { this.notificationHandler.AckRecipient(ackStatus, smtpResponse, recipient); } return; default: throw new InvalidOperationException(string.Format("AckRecipient with status: {0} is invalid", ackStatus)); } }
private static void AckMailItemOnRetryException(AckStatus status, MbxTransportMailItem mailItem, RetryException exception, string sourceContext, ulong sessionId, ulong bytesDelivered, ulong recipientCount) { StoreDriverDeliveryDiagnostics.Diag.TraceDebug <RetryException, AckStatus>(0L, "StoreDriverDelivery encountered an exception {0}. Message Action: {1}.", exception, status); if (exception.MessageStatus.Action == MessageAction.RetryQueue) { mailItem.MessageLevelAction = MessageAction.RetryQueue; } mailItem.AckMailItem(status, exception.MessageStatus.Response, new AckDetails(StoreDriverDelivery.localHostName), exception.MessageStatus.RetryInterval, sourceContext); StoreDriverDelivery.LogRetryExceptionInConnectionLog(exception, mailItem, sourceContext, sessionId, bytesDelivered, recipientCount); }
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"); } } }
/// <summary> /// Callback for deferred message acknowledge /// </summary> /// <param name="id">DeliveryTag of the message</param> /// <param name="status">Action for acknowledge: Ack - delete from queue, Reject - requeue, etc.</param> public void Acknowledge(ulong id, AckStatus status) { if (ManualAcknowledgement && !_channel.IsClosed) { try { switch (status) { case AckStatus.Ack: _channel.BasicAck(deliveryTag: id, multiple: false); break; default: _channel.BasicReject(deliveryTag: id, requeue: true); break; } } catch { } } }
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; } }
public virtual void AckRecipient(AckStatus ackStatus, SmtpResponse smtpResponse) { this.recipientResponses.Enqueue(new AckStatusAndResponse(ackStatus, smtpResponse)); }