public EventPublishOptions GetEventPublishOptions(IEventProcessor eventProcessor) { if (_eventPublishOptions.TryGetValue(eventProcessor.GetType().FullName, out EventPublishOptions options)) { return(options); } else { return(null); } }
private async Task ProcessEvents(IEnumerable <IEventWrapper> wrappedEvents) { var methodInfo = _eventProcessor.GetType().GetMethod("Process"); //Parallel.ForEach(wrappedEvents, async wrappedEvent => { // var wrappedEventType = wrappedEvent.GetType().GetTypeInfo().GetGenericArguments()[0]; // await (Task)methodInfo.MakeGenericMethod(wrappedEventType) // .Invoke(_eventProcessor, new object[] { wrappedEvent }); //}); foreach (var wrappedEvent in wrappedEvents) { var wrappedEventType = wrappedEvent.GetType().GetTypeInfo().GenericTypeArguments[0]; await(Task) methodInfo.MakeGenericMethod(wrappedEventType) .Invoke(_eventProcessor, new object[] { wrappedEvent }); } }
private Task StartEventProcessor(IEventProcessor eventProcessor, string consumerGroupName, bool realTimeOnly) { _eventProcessorHost = new EventProcessorHost(Environment.MachineName, _config.EventHubRecieverPath, consumerGroupName, _config.EventHubConnectionString, _config.EventHubStorageConnectionString); //We need these options to var options = new EventProcessorOptions(); if (realTimeOnly) { options.InitialOffsetProvider = OnlyNewDataOffsetProvider; } //Look at implementing these //options.InvokeProcessorAfterReceiveTimeout = true; //options.PrefetchCount = 1000; //options.ExceptionReceived += options_ExceptionReceived; var type = eventProcessor.GetType(); return(_eventProcessorHost.RegisterEventProcessorFactoryAsync(new EventProcessorFactory(type), options)); }