void Defer(TimeSpan defer, TransportMessage message) { var retryMessageAt = DateTime.UtcNow + defer; TransportMessageHeaderHelper.SetHeader(message, Headers.Retries, (TransportMessageHeaderHelper.GetNumberOfRetries(message) + 1).ToString(CultureInfo.InvariantCulture)); var addressOfFaultingEndpoint = TransportMessageHeaderHelper.GetAddressOfFaultingEndpoint(message); if (!TransportMessageHeaderHelper.HeaderExists(message, SecondLevelRetriesHeaders.RetriesTimestamp)) { TransportMessageHeaderHelper.SetHeader(message, SecondLevelRetriesHeaders.RetriesTimestamp, DateTimeExtensions.ToWireFormattedString(DateTime.UtcNow)); } logger.DebugFormat("Defer message and send it to {0}", addressOfFaultingEndpoint); var sendOptions = new SendOptions(addressOfFaultingEndpoint) { DeliverAt = retryMessageAt }; MessageDeferrer.Defer(message, sendOptions); }
void Defer(TimeSpan defer, TransportMessage message) { var retryMessageAt = DateTime.UtcNow + defer; TransportMessageHelpers.SetHeader(message, Headers.Retries, (TransportMessageHelpers.GetNumberOfRetries(message) + 1).ToString()); var addressOfFaultingEndpoint = TransportMessageHelpers.GetAddressOfFaultingEndpoint(message); if (!TransportMessageHelpers.HeaderExists(message, SecondLevelRetriesHeaders.RetriesTimestamp)) { TransportMessageHelpers.SetHeader(message, SecondLevelRetriesHeaders.RetriesTimestamp, DateTimeExtensions.ToWireFormattedString(DateTime.UtcNow)); } Logger.DebugFormat("Defer message and send it to {0}", addressOfFaultingEndpoint); MessageDeferrer.Defer(message, retryMessageAt, addressOfFaultingEndpoint); }
public ICallback Defer(DateTime processAt, params object[] messages) { if (messages == null || messages.Length == 0) { throw new InvalidOperationException("Cannot Defer an empty set of messages."); } if (processAt.ToUniversalTime() <= DateTime.UtcNow) { return(SendLocal(messages)); } var toSend = new TransportMessage(); MapTransportMessageFor(messages, toSend); toSend.Headers[Headers.IsDeferredMessage] = Boolean.TrueString; MessageDeferrer.Defer(toSend, processAt, Address.Local); return(SetupCallback(toSend.Id)); }