Beispiel #1
0
        protected virtual void RegisterReceiverMessageHandler(Action <BrokeredMessage> receiverMessageHandler, OnMessageOptions receiverMessageHandlerOptions)
        {
            ReceiverMessageHandler        = receiverMessageHandler;
            ReceiverMessageHandlerOptions = receiverMessageHandlerOptions;

            ServiceBusReceiver.OnMessage(ReceiverMessageHandler, ReceiverMessageHandlerOptions);
        }
Beispiel #2
0
        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();
                }
            });
        }
Beispiel #3
0
        public void Start()
        {
            InstantiateReceiving();

            // Configure the callback options
            OnMessageOptions options = new OnMessageOptions
            {
                AutoComplete     = false,
                AutoRenewTimeout = TimeSpan.FromMinutes(1)
            };

            // Callback to handle received messages
            ServiceBusReceiver.OnMessage(ReceiveEvent, options);
        }