Esempio n. 1
0
        private static IModel Initialize(RabbitMQOptions options)
        {
            var connectionFactory = new ConnectionFactory();

            connectionFactory.HostName = options.HostName;
            connectionFactory.Port     = options.PortNumber;
            connectionFactory.UserName = options.UserName;
            connectionFactory.Password = options.Password;

            var connection = connectionFactory.CreateConnection();
            var channel    = connection.CreateModel();

            return(channel);
        }
Esempio n. 2
0
        private static bool ValidateOptions(RabbitMQOptions options)
        {
            if (options == null)
            {
                return(false);
            }

            if (string.IsNullOrWhiteSpace(options.HostName) || string.IsNullOrWhiteSpace(options.UserName) ||
                string.IsNullOrWhiteSpace(options.Password) || !(options.PortNumber > 0))
            {
                return(false);
            }

            return(true);
        }