工作者角色 - EventProcessorHost CheckPoint 似乎导致 409 冲突 Azure 存储

Worker role - EventProcessorHost CheckPoint seems cause 409 Conflict Azure Storage

我有一个云服务和一个带有 2 个分区的事件中心。 我的云服务是写入 Azure 存储的辅助角色。它写入从事件中心接收到的所有消息。

使用 Azure 模拟器,我的工作者角色工作正常,它写入生产中的 Azure 存储(不是开发,所以它是相同的 azure 存储)。

当我将工作者角色推送到云服务时,我从 Application Insight 收到此类错误(100% 成功调用:false)。使用 IntelliTrace 日志,我得到了 409 冲突。

我尝试远程调试,但它太慢了,我重写代码的时间比等待 'next step'...

我删除了代码中的所有租约管理,但没有任何改变...

我坚信这与检查点问题有关。

_host = new EventProcessorHost(Environment.MachineName, eventHubName, consumerGroupName, eventHubConnectionString, checkpointConnectionString);

我在此方法中使用我的检查点(在我的 HandledEventProcessor 中)

    public async Task ProcessEventsAsync(PartitionContext context, IEnumerable<EventData> events)
    {
        try
        {
            foreach (EventData eventData in events)
            {
                var eventName = eventData.GetEventName();
                var handlers = _handlerFactory.GetHandlers(eventName);
                if (handlers.Any())
                {
                    foreach (var handler in handlers)
                    {
                        SafelyHandleEvent(handler, eventName, eventData, context);
                    }
                }
                else
                {
                    _log.WarnEvent("NoEventHandlers",
                        new Facet { Name = "eventName", Value = eventName });
                }
            }
            await context.CheckpointAsync(); <--- Checkpoint here
        }
        catch (Exception ex)
        {
            _log.ErrorEvent("ProcessEventsFailed", ex,
                new Facet { Name = "eventCount", Value = events.Count() },
                new Facet { Name = "eventHubPath", Value = context.EventHubPath },
                new Facet { Name = "partitionId", Value = context.Lease.PartitionId });
        }
    }

Application Insight 日志

23/4/2016 10:35:01 - 依赖 天蓝色斑点:myblobStorage/myContainer 依赖持续时间:2.84 毫秒 调用成功:false URL: https://****.blob.core.windows.net:443/myContainer/myConsumerGroupName/partition1

23/4/2016 10:35:01 - 依赖 天蓝色斑点:myblobStorage/myContainer 依赖持续时间:2.84 毫秒 调用成功:false URL: https://****.blob.core.windows.net:443/myContainer/myConsumerGroupName/partition0

2016 年 4 月 23 日 10:34:59 - 依赖 天蓝色斑点:myblobStorage/myContainer 依赖持续时间:4.4 msSuccessful call: falseURL: https://****.blob.core.windows.net:443/myContainer/myConsumerGroupName/1?comp=lease&timeout=10

2016 年 4 月 23 日 10:34:59 - 依赖 天蓝色斑点:myblobStorage/myContainer 依赖持续时间:4.4 msSuccessful call: falseURL: https://****.blob.core.windows.net:443/myContainer/myConsumerGroupName/0?comp=lease&timeout=10

我没听懂这个...如果有人有想法,非常欢迎...

如有任何帮助,我们将不胜感激。

我在调用 await context.CheckpointAsync();

之前添加了一个计时器

我认为根据事件的数量,如果 await context.CheckpointAsync(); 在短时间内被多次调用,这是行不通的...

当然,我是在事态低迷时部署的。