【问题标题】:Is there any way to read from specific EventHub Partition using EventProcessorHost有什么方法可以使用 EventProcessorHost 从特定的 EventHub 分区中读取
【发布时间】:2018-05-21 22:15:31
【问题描述】:

我有一个 ServiceFabric 无状态服务,我想使用 EventProcessorHost 从特定的 EventHub 分区中读取数据。 我想读取两个事件中心分区,每个分区映射到一个 EventProcessorHost

第一个 EventHub 分区 => 第一个 EventProcessorHost
第二个 EventHub 分区 => 第二个 EventProcessorHost

  var eventHubClient = EventHubClient.CreateFromConnectionString(serviceBusConnectionString, eventHubName);

            // Get the default Consumer Group
            eventProcessorHost = new EventProcessorHost(Guid.NewGuid().ToString(),
                                                        eventHubClient.Path.ToLower(),                                                            
                                                        consumerGroupName.ToLower(),
                                                        serviceBusConnectionString,
                                                        storageAccountConnectionString)
            {
                PartitionManagerOptions = new PartitionManagerOptions
                {
                    AcquireInterval = TimeSpan.FromSeconds(10), // Default is 10 seconds
                    RenewInterval = TimeSpan.FromSeconds(10), // Default is 10 seconds
                    LeaseInterval = TimeSpan.FromSeconds(30) // Default value is 30 seconds
                }
            };

            ServiceEventSource.Current.Message(RegisteringEventProcessor);
            var eventProcessorOptions = new EventProcessorOptions
            {
                InvokeProcessorAfterReceiveTimeout = true,
                MaxBatchSize = 100,
                PrefetchCount = 100,
                ReceiveTimeOut = TimeSpan.FromSeconds(30),
            };
            eventProcessorOptions.ExceptionReceived += EventProcessorOptions_ExceptionReceived;
            await eventProcessorHost.RegisterEventProcessorFactoryAsync(new EventProcessorFactory<EventProcessor>(deviceActorServiceUri),
                                                                        eventProcessorOptions);

【问题讨论】:

    标签: azure-service-fabric azure-eventhub service-fabric-stateless


    【解决方案1】:

    有一个 github 存储库有一个可以从 here 构建的实现。 好久没维护了,不过好像可以解决你的问题。

    4- 单个:将单个事件中心分区映射到单个服务结构分区。 事件中心通信侦听器将期望提供的有效事件中心分区 ID

    【讨论】:

    • 感谢您的回复,在此解决方案中,它使用的是 "EventHubReceiver"。但是我通过使用 "IEventProcessor" 来寻找类似的东西
    猜你喜欢
    • 2021-03-25
    • 2020-04-02
    • 1970-01-01
    • 1970-01-01
    • 2018-04-03
    • 2020-05-11
    • 2021-03-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多