I developed an example application for checking timeout control in a saga using NserviceBus.
I am trying to achieve the following
When the saga started to set the timeout to 1 minute before the timeout expires, if the update came to the update, the timeout update to 5 minutes My code looks below
public class OrderSaga : Saga<OrderSagaData>, IAmStartedByMessages<SampleMessage>, IHandleMessages<UpdateMessage> { public override void ConfigureHowToFindSaga() { ConfigureMapping<UpdateMessage>(s => s.PurchaseOrderNumber, m => m.Update); } public void Handle(SampleMessage message) { this.Data.PurchaseOrderNumber = message.Name; RequestTimeout(DateTime.Now.AddMinutes(1), message.Name); } private void Complete() { MarkAsComplete(); } public override void Timeout(object state) { Complete(); } #region IMessageHandler<UpdateMessage> Members public void Handle(UpdateMessage message) { this.Data.PurchaseOrderNumber = message.NewValue; RequestTimeout(DateTime.Now.AddMinutes(5), message.Update); } #endregion } }
But the problem here is that the timeout is not updated to 5 minutes. The timeout is still running for 1 minute.
Could you tell me what is being done wrong here?
Thanks in advance, Ajay
source share