我有一个ServiceFabric无状态服务,我希望使用EventProcessorHost从特定的EventHub分区中读取。 我想从两个事件中心分区映射中读取每个到一个EventProcessorHost
First EventHub Partition =>第一个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);
答案 0 :(得分:0)
有一个github仓库,它有一个你可以从here构建的实现。 它已经维持了很长一段时间,但它似乎可以解决你的问题。
4- Single:将单个事件中心分区映射到单个服务结构分区。 Event Hub通信侦听器将期望提供有效的事件中心分区标识