/// <summary> /// Initialization of EventHub receiver is performed at adapter reciever initialization, but if it fails, /// it will be retried when messages are requested /// </summary> /// <returns></returns> private async Task Initialize() { var watch = Stopwatch.StartNew(); try { checkpointer = await checkpointerFactory(settings.Partition); cache = cacheFactory(settings.Partition, checkpointer, baseLogger); flowController = new AggregatedQueueFlowController(MaxMessagesPerRead) { cache, LoadShedQueueFlowController.CreateAsPercentOfLoadSheddingLimit(getNodeConfig) }; string offset = await checkpointer.Load(); receiver = await this.eventHubReceiverFactory(settings, offset, logger); watch.Stop(); monitor?.TrackInitialization(true, watch.Elapsed, null); } catch (Exception ex) { watch.Stop(); monitor?.TrackInitialization(false, watch.Elapsed, ex); throw; } }
/// <summary> /// Initialization of EventHub receiver is performed at adapter receiver initialization, but if it fails, /// it will be retried when messages are requested /// </summary> /// <returns></returns> private async Task Initialize() { var watch = Stopwatch.StartNew(); try { this.checkpointer = await this.checkpointerFactory(this.settings.Partition); if (this.cache != null) { this.cache.Dispose(); this.cache = null; } this.cache = this.cacheFactory(this.settings.Partition, this.checkpointer, this.loggerFactory, this.telemetryProducer); this.flowController = new AggregatedQueueFlowController(MaxMessagesPerRead) { this.cache, LoadShedQueueFlowController.CreateAsPercentOfLoadSheddingLimit(this.loadSheddingOptions) }; string offset = await this.checkpointer.Load(); this.receiver = this.eventHubReceiverFactory(this.settings, offset, this.logger, this.telemetryProducer); watch.Stop(); this.monitor?.TrackInitialization(true, watch.Elapsed, null); } catch (Exception ex) { watch.Stop(); this.monitor?.TrackInitialization(false, watch.Elapsed, ex); throw; } }