I have the following code. It runs fine up, I see the messaged printed to the log, but saga does not finalize (is being kept alive in the repository causing memory leaks).
During(WaitingForMixResponse,
When(ResultReady)
.Unschedule(MixTimedOut)
.Publish(m => new SaveMix(Guid.NewGuid(), m.Instance.MixedResult))
.Then(m => _logger.Info("Mix saved.")))
.Finalize();
If I comment both Unschedule and Publish, it gets finalized and removed from the repository.
Also, if I put the Finalize on the top of the chain like below, then everything works.
During(WaitingForMixResponse,
When(ResultReady)
.Finalize()
.Unschedule(MixTimedOut)
.Publish(m => new SaveMix(Guid.NewGuid(), m.Instance.MixedResult))
.Then(m => _logger.Info("Mix saved.")));
As far as I understand, the order of the Finalize shouldn't matter. I'm using MT 3.3.5, but reproduced on earlier versions. There are other states in my Saga, but the behaviour is displayed across several other Sagas. I'm calling SetCompletedWhenFinalized(); in all constructors.
Any ideas?