/// <summary> /// Dispatches the message to the saga and, based on the saga's state /// persists it or notifies of its completion to interested parties. /// </summary> /// <param name="saga"></param> /// <param name="message"></param> /// <param name="sagaIsPersistent"></param> protected virtual void HaveSagaHandleMessage(ISaga saga, IMessage message, bool sagaIsPersistent) { var tm = message as TimeoutMessage; if (tm != null) { saga.Timeout(tm.State); } else { CallHandleMethodOnSaga(saga, message); } if (!saga.Completed) { if (!sagaIsPersistent) { Persister.Save(saga.Entity); } else { Persister.Update(saga.Entity); } } else { if (sagaIsPersistent) { Persister.Complete(saga.Entity); } NotifyTimeoutManagerThatSagaHasCompleted(saga); } LogIfSagaIsFinished(saga); }