protected virtual void TriggerConnectionSettingsChecking() { Task.Factory.StartNew(() => { SpinWait.SpinUntil(() => ConnectionString != ConfigurationManager.GetSetting(MessageBusConnectionStringConfigurationKey)); Logger.LogInfo("Connecting string settings for the Azure Service Bus changed and will now refresh."); // Update the connection string and trigger a restart; ConnectionString = ConfigurationManager.GetSetting(MessageBusConnectionStringConfigurationKey); Logger.LogDebug(string.Format("Updated connecting string settings set to {0}.", ConnectionString)); // Let's wrap up using this message bus and start the switch if (ServiceBusPublisher != null) { ServiceBusPublisher.Close(); Logger.LogDebug("Publishing service bus closed."); } // Let's wrap up using this message bus and start the switch if (ServiceBusReceiver != null) { ServiceBusReceiver.Close(); Logger.LogDebug("Receiving service bus 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 (ServiceBusReceiver != 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."); ServiceBusReceiver.OnMessage(ReceiverMessageHandler, ReceiverMessageHandlerOptions); } 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 (ServiceBusPublisher != null) { Logger.LogDebug("Recursively calling into InstantiatePublishing."); InstantiatePublishing(); } }); }
protected override void TriggerSettingsChecking() { // Let's wrap up using this message bus and start the switch if (ServiceBusPublisher != null) { ServiceBusPublisher.Close(); Logger.LogDebug("Publishing service bus closed."); } foreach (SubscriptionClient serviceBusReceiver in ServiceBusReceivers.Values) { // Let's wrap up using this message bus and start the switch if (serviceBusReceiver != null) { serviceBusReceiver.Close(); Logger.LogDebug("Receiving service bus 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 (serviceBusReceiver != 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 (ServiceBusPublisher != null) { Logger.LogDebug("Recursively calling into InstantiatePublishing."); InstantiatePublishing(); } }