Пример #1
0
        /// <summary>
        /// Request for a timeout to occur at the given time
        /// </summary>
        /// <param name="at"></param>
        /// <param name="timeoutMessage"></param>
        protected void RequestUtcTimeout <TTimeoutmessageType>(DateTime at, TTimeoutmessageType timeoutMessage)
        {
            if (at.Kind == DateTimeKind.Unspecified)
            {
                throw new InvalidOperationException("Kind property of DateTime 'at' must be specified.");
            }

            object toSend = timeoutMessage;

            if (!typeof(TTimeoutmessageType).IsMessageType())
            {
                toSend = new TimeoutMessage(at, Data, toSend);
            }

            SetHeaders(toSend);

            if (at.ToUniversalTime() <= DateTime.UtcNow)
            {
                Bus.SendLocal(toSend);
            }
            else
            {
                Bus.Defer(at, toSend);
            }
        }
Пример #2
0
        /// <summary>
        /// Request for a timeout to occur within the give timespan
        /// </summary>
        /// <param name="within"></param>
        /// <param name="timeoutMessage"></param>
        protected void RequestUtcTimeout <TTimeoutmessageType>(TimeSpan within, TTimeoutmessageType timeoutMessage)
        {
            object toSend = timeoutMessage;

            if (!typeof(TTimeoutmessageType).IsMessageType())
            {
                toSend = new TimeoutMessage(within, Data, toSend);
            }

            SetHeaders(toSend);

            Bus.Defer(within, toSend);
        }
Пример #3
0
        /// <summary>
        /// Request for a timeout to occur within the give timespan
        /// </summary>
        /// <param name="within"></param>
        /// <param name="timeoutMessage"></param>
        protected void RequestUtcTimeout <TTimeoutmessageType>(TimeSpan within, TTimeoutmessageType timeoutMessage)
        {
            object toSend = timeoutMessage;

            if (!typeof(TTimeoutmessageType).IsMessageType())
            {
                toSend = new TimeoutMessage(within, Data, toSend);
            }

            toSend.SetHeader(Headers.SagaId, Data.Id.ToString());
            toSend.SetHeader("NServiceBus.SagaDataType", Data.GetType().AssemblyQualifiedName);
            if (within <= TimeSpan.Zero)
            {
                Bus.SendLocal(toSend);
            }
            else
            {
                Bus.Defer(within, toSend);
            }
        }
Пример #4
0
        /// <summary>
        /// Request for a timeout to occur within the give timespan
        /// </summary>
        /// <param name="within"></param>
        /// <param name="timeoutMessage"></param>
        protected void RequestUtcTimeout <TTIMEOUTMESSAGETYPE>(TimeSpan within, TTIMEOUTMESSAGETYPE timeoutMessage)
        {
            object toSend = timeoutMessage;

            if (!toSend.IsMessage())
            {
                toSend = new TimeoutMessage(within, Data, toSend);
            }

            toSend.SetHeader(Headers.SagaId, Data.Id.ToString());

            if (within <= TimeSpan.Zero)
            {
                Bus.SendLocal(toSend);
            }
            else
            {
                Bus.Defer(within, toSend);
            }
        }
Пример #5
0
 /// <summary>
 /// Message handler for Timeout Message
 /// </summary>
 /// <param name="message">Timeout Message</param>
 public void Handle(TimeoutMessage message)
 {
     Timeout(message.State);
 }