【问题标题】:Azure Table Storage Concurrency IssueAzure 表存储并发问题
【发布时间】:2014-05-14 04:10:19
【问题描述】:

似乎与 Azure 的并发冲突引发异常,消息包含错误代码 412。除了检查 StorageException 的错误消息是否包含412在留言?这似乎是一种真正的字符串类型方法。

【问题讨论】:

  • razingtheivorytower.blogspot.com/2012/09/…。您可以检查StatusCode = 412,它仍然是一个幻数,但不匹配错误字符串。
  • 啊,我错过了。如果您想将链接放入答案中,我会接受。这正是我想要的。

标签: azure concurrency azure-table-storage optimistic-concurrency


【解决方案1】:

使用“RequestInformation.HttpStatusCode 似乎对我有用

    try
    {
        TableOperation operation = TableOperation.Merge(ent);
        retval = await table.ExecuteAsync(operation);
    }
    catch (StorageException sex)
    {
        if (sex.RequestInformation.HttpStatusCode == (int)HttpStatusCode.PreconditionFailed)
        {
            TableOperation retrieveOperation = TableOperation.Retrieve<BotSetting>(ent.PartitionKey, ent.RowKey);
            TableResult retrievedResult = await table.ExecuteAsync(retrieveOperation);
            if (retrievedResult.Result != null)
            {
                BotSetting bs = retrievedResult.Result as BotSetting;
                retval = await TryMerge(table, bs, tries--);
            }
        }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-19
    • 2013-06-05
    • 1970-01-01
    • 2022-01-15
    • 1970-01-01
    • 2017-01-06
    • 1970-01-01
    相关资源
    最近更新 更多