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

时间:2016-04-23 15:20:13

标签: azure azure-storage-blobs azure-worker-roles azure-cloud-services event-processor-host

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

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

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

我试图进行远程调试但速度太慢以至于我将花费更少的时间来重写代码,而不是等待“下一步”......

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

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

_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 - 依赖性 Azure blob:myblobStorage / myContainer 依赖期:2.84毫秒 成功通话:假 网址:https://****.blob.core.windows.net:443 / myContainer / myConsumerGroupName / partition1

23/4/2016 10:35:01 - 依赖性 Azure blob:myblobStorage / myContainer 依赖期:2.84毫秒 成功通话:假 网址:https://****.blob.core.windows.net:443 / myContainer / myConsumerGroupName / partition0

23/4/2016 10:34:59 - 依赖性 Azure blob:myblobStorage / myContainer 依赖期限:4.4 ms成功通话:falseURL:https://****.blob.core.windows.net:443 / myContainer / myConsumerGroupName / 1?comp = lease&amp; timeout = 10

23/4/2016 10:34:59 - 依赖性 Azure blob:myblobStorage / myContainer 依赖期限:4.4 ms成功通话:falseURL:https://****.blob.core.windows.net:443 / myContainer / myConsumerGroupName / 0?comp = lease&amp; timeout = 10

我没有抓住这个......如果有人有想法,那就非常受欢迎......

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:0)

我添加了一个调用await context.CheckpointAsync();

的计时器befors

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

当然,我在事件发生的时候部署了......