예제 #1
0
        /// <summary>
        /// Verifies the pool states.
        /// </summary>
        /// <param name="connectionName">Name of the connection.</param>
        /// <param name="queueName">Name of the queue.</param>
        /// <param name="exchangeName">Name of the exchange.</param>
        /// <param name="queueArgs">The queue arguments.</param>
        /// <param name="exchangeArgs">The exchange arguments.</param>
        /// <returns></returns>
        /// <exception cref="Exception">
        /// </exception>
        protected ConfigStates VerifyPoolStates(
            string connectionName,
            string queueName,
            string exchangeName = null,
            IDictionary <string, object> queueArgs    = null,
            IDictionary <string, object> exchangeArgs = null)
        {
            var states = new ConfigStates
            {
                Connection  = _configurationManager.GetConnectionSettings(connectionName),
                Destination = _configurationManager.GetQueueSettings(queueName),
                Exchange    = string.IsNullOrWhiteSpace(exchangeName) ? null : _configurationManager.GetExchangeSettings(exchangeName),
            };

            if (string.IsNullOrWhiteSpace(states.Connection.Uri))
            {
                throw new Exception($"Connection: {connectionName} is not configured or is missing from configuration.");
            }

            if (string.IsNullOrWhiteSpace(states.Destination.QueueName))
            {
                throw new Exception($"Queue: {queueName} is not configured or is missing from configuration.");
            }

            if (states.Exchange != null && string.IsNullOrWhiteSpace(states.Exchange.ExchangeName))
            {
                throw new Exception($"Exchange: {exchangeName} is not configured or is missing from configuration.");
            }

            return(states);
        }
예제 #2
0
        /// <summary>
        /// Verifies the pool states.
        /// </summary>
        /// <param name="connectionName">Name of the connection.</param>
        /// <param name="queueName">Name of the queue.</param>
        /// <returns></returns>
        /// <exception cref="Exception">
        /// </exception>
        protected ConfigStates VerifyPoolStates(string connectionName, string queueName)
        {
            var states = new ConfigStates
            {
                Connection  = _configurationManager.GetConnectionSettings(connectionName),
                Destination = _configurationManager.GetDestinationSettings(queueName),
            };

            if (string.IsNullOrWhiteSpace(states.Connection.Uri))
            {
                throw new Exception($"Connection: {connectionName} is not configured or is missing from configuration.");
            }

            if (string.IsNullOrWhiteSpace(states.Destination.Path))
            {
                throw new Exception($"Queue: {queueName} is not configured or is missing from configuration.");
            }

            return(states);
        }