0

我有一个云服务和一个带有 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 毫秒成功调用:错误 URL:https://****.blob.core.windows.net:443/myContainer/ myConsumerGroupName/partition1

23/4/2016 10:35:01 - 依赖 Azure blob:myblobStorage/myContainer 依赖持续时间:2.84 毫秒成功调用:错误 URL: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

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

任何帮助,将不胜感激。

4

1 回答 1

0

我在打电话之前添加了一个计时器await context.CheckpointAsync();

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

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

于 2016-04-25T13:54:41.487 回答