【问题标题】:Worker role - EventProcessorHost CheckPoint seems cause 409 Conflict Azure Storage辅助角色 - EventProcessorHost CheckPoint 似乎导致 409 冲突 Azure 存储
【发布时间】:2023-10-10 23:33:01
【问题描述】:

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

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

当我将工作人员角色推送到云服务时,我从 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 毫秒 调用成功:false 网址:https://****.blob.core.windows.net:443/myContainer/myConsumerGroupName/partition1

23/4/2016 10:35:01 - 依赖 Azure blob:myblobStorage/myContainer 依赖持续时间:2.84 毫秒 调用成功:false 网址:https://****.blob.core.windows.net:443/myContainer/myConsumerGroupName/partition0

23/4/2016 10:34:59 - 依赖 Azure blob:myblobStorage/myContainer 依赖持续时间:4.4 毫秒成功调用:falseURL:https://****.blob.core.windows.net:443/myContainer/myConsumerGroupName/1?comp=lease&timeout=10

23/4/2016 10:34:59 - 依赖 Azure blob:myblobStorage/myContainer 依赖持续时间:4.4 毫秒成功调用:falseURL:https://****.blob.core.windows.net:443/myContainer/myConsumerGroupName/0?comp=lease&timeout=10

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

任何帮助将不胜感激。

【问题讨论】:

  • 部署后是否立即收到该错误,是否有任何成功的操作?
  • 感谢您的帮助!看我的回答。

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


【解决方案1】:

我在调用await context.CheckpointAsync();之前添加了一个计时器

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

当然,我在事件低谷时部署..

【讨论】: