/// <summary> /// Triggers settings checking on <see cref="EventHubPublisher"/> and <see cref="EventHubReceiver"/>, /// then calls <see cref="InstantiateReceiving"/> and <see cref="InstantiatePublishing"/>. /// </summary> protected override void TriggerSettingsChecking() { // Let's wrap up using this event hub and start the switch if (EventHubPublisher != null) { EventHubPublisher.Close(); Logger.LogDebug("Publishing event hub closed."); } // Let's wrap up using this event hub and start the switch if (EventHubReceiver != null) { Task work = EventHubReceiver.UnregisterEventProcessorAsync(); work.ConfigureAwait(false); work.Wait(); Logger.LogDebug("Receiving event hub closed."); } // Restart configuration, we order this intentionally with the receiver first as if this triggers the cancellation we know this isn't a publisher as well if (EventHubReceiver != null) { Logger.LogDebug("Recursively calling into InstantiateReceiving."); InstantiateReceiving(); // This will be the case of a connection setting change re-connection if (ReceiverMessageHandler != null && ReceiverMessageHandlerOptions != null) { // Callback to handle received messages Logger.LogDebug("Re-registering onMessage handler."); ApplyReceiverMessageHandler(); } else { Logger.LogWarning("No onMessage handler was found to re-bind."); } } // Restart configuration, we order this intentionally with the publisher second as if this triggers the cancellation there's nothing else to process here if (EventHubPublisher != null) { Logger.LogDebug("Recursively calling into InstantiatePublishing."); InstantiatePublishing(); } }