protected override Expression <Func <RabbitMqExchangeOptions, bool> > ToExpression()
        {
            var allowedExchangeTypes = ExchangeType.All() !;

            // Do not validate dead letter exchange type if actual DeadLetterExchange is empty.
            return(options => string.IsNullOrEmpty(options.DeadLetterExchange) || allowedExchangeTypes.Contains(options.DeadLetterExchangeType));
        }
コード例 #2
0
        public void TestExchangeTypeValidation()
        {
            string             uriLike = "direct:///";
            PublicationAddress addr    = PublicationAddress.Parse(uriLike);
            int found = 0;

            foreach (string exchangeType in ExchangeType.All())
            {
                if (exchangeType.Equals(addr.ExchangeType))
                {
                    found++;
                }
            }
            Assert.AreEqual(1, found);
        }
コード例 #3
0
        /// <summary>
        /// Exchange declare
        /// </summary>
        /// <param name="exchangeName">exchange name</param>
        /// <param name="exchangeType">exchange type <see cref="ExchangeType"/></param>
        /// <param name="isDurable">is durable</param>
        /// <param name="isAutoDelete">is auto delete</param>
        /// <param name="arguments">arguments,default is null</param>
        public void ExchangeDeclare(string exchangeName, string exchangeType, bool isDurable, bool isAutoDelete = false, IDictionary <string, object> arguments = null)
        {
            Check.Argument.IsNotEmpty(exchangeName, nameof(exchangeName));
            Check.Argument.IsNotEmpty(exchangeName, nameof(exchangeType));

            exchangeType = exchangeType.ToLower();
            if (!ExchangeType.All().Contains(exchangeType))
            {
                Check.Argument.IsNotValid(exchangeType, nameof(exchangeType));
            }

            using (IConnection connection = _RabbitmqProvider.CreateCollection())
            {
                using (IModel channel = connection.CreateModel())
                {
                    channel.ExchangeDeclare(exchangeName, exchangeType, isDurable, isAutoDelete, arguments);
                }
            }
        }
        protected override Expression <Func <RabbitMqExchangeOptions, bool> > ToExpression()
        {
            var allowedExchangeTypes = ExchangeType.All() !;

            return(options => allowedExchangeTypes.Contains(options.Type));
        }