0

I have a saga data class with one property marked by Unique attribute. However, this didn't prevent NServiceBus from creating several sagas with identical values in this field.

Here is my data class:

public class ModuleAliveSagaData : ContainSagaData
{
    [Unique]
    public string ModuleId { get; set; }
    public string Endpoint { get; set; }
    public string Module { get; set; }
    public DateTime LastCheck { get; set; }
    public bool Warning { get; set; }
    public bool Error { get; set; }
}

Here is the mapping:

public override void ConfigureHowToFindSaga()
{
    ConfigureMapping<ModuleAliveMessage>(m => m.Id).ToSaga(s => s.ModuleId);
}

Here is how data gets its values:

    public void Handle(ModuleStartedMessage message)
    {
        Log.InfoFormat("Module {0} started on {1} at {2}", message.ModuleName, message.Endpoint, message.Timestamp);
        Data.ModuleId = message.Id;
        Data.Endpoint = message.Endpoint;
        Data.Module = message.ModuleName;
        Data.LastCheck = DateTime.Now;
        Data.Warning = false;
        Bus.SendLocal(new SendNotification
        {
            Subject = string.Format("Module {0} is online at {1}", Data.Module, Data.Endpoint)
        });
        RequestTimeout<ModuleCheckTimeout>(TimeSpan.FromMinutes(5));
        Bus.Publish(new ModuleActivated
        {
            Endpoint = message.Endpoint,
            Module = message.ModuleName
        });
    }

And here is what I see in the saga persistence table (Azure table storage):

Does it suppose to work like this or may be I am missing something?

enter image description here

4

1 回答 1

0

伊夫在评论中写了这个,基本上这是正确的答案:

除了 partitionkey/rowkey 对之外,Azure 存储无法检查唯一性,因此该属性被忽略。如果您需要独特性,您将不得不考虑另一种存储技术。PS:这是底层存储的已知限制:http: //github.com/Particular/NServiceBus.Azure/issues/21

于 2015-03-14T11:50:13.863 回答