【问题标题】:On listening from Azure Event Hub I am getting error从 Azure 事件中心收听时出现错误
【发布时间】:2018-03-06 14:13:01
【问题描述】:

从 Azure 事件中心收听时出现错误

提供的偏移量 XXXXX 无效。系统中的最后一个偏移量是 XXXXX

分区 1 上的错误:AMQP 对象会话被中止。 分区 0 上的错误:提供的偏移量无效。

【问题讨论】:

  • 您是否提供偏移量?如果是这样,你有一个错误的。 this 有用吗?
  • 不,我没有提供任何偏移量。
  • 我是从 IEventProcessor 继承的,所以我没有提供任何偏移量。
  • 而且您没有将任何参数传递给/设置EventProcessorHost 的任何属性?你能把你做初始化的代码贴出来吗?

标签: azure-eventhub


【解决方案1】:

我有同样的问题。这是因为共享了一个 EventPosition 类的实例。

var position = EventPosition.FromStart();

var eventProcessorHost = new EventProcessorHost(
    eventHubName,
    consumerGroupName,
    eventHubConnectionString,
    storageConnectionString,
    LeaseContainerName);

host.RegisterEventProcessorFactoryAsync(
    processorFactory,
    new EventProcessorOptions
    {
        // Problem is the following line.
        // In order to fix it replace 'position' with 'EventPosition.FromStart()'
        InitialOffsetProvider = partitionId => position  
    }).Wait();

显然,如果您共享一个位置类的实例,那么 ProcessorHost 对不同的 IEventProcessor(s) 使用相同的对象。由于此对象包含偏移值,因此会导致将相同的偏移量传递给不同的分区 - 显然,如果分区之间的偏移量不同,则会导致问题。

【讨论】:

    猜你喜欢
    • 2020-05-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多