Exemplo n.º 1
0
        internal static void Init(RabbitMQOptions options)
        {
            Options           = options ?? throw new ArgumentNullException(nameof(options));
            ConnectionFactory = CreateFactory(options);
            if (options.HostNames?.Count > 0)
            {
                HostNames = options.HostNames;
            }

            if (options.Endpoints?.Count > 0)
            {
                EndPoints = (from dic in options.Endpoints
                             select new AmqpTcpEndpoint()
                {
                    HostName = dic.Key,
                    Port = dic.Value
                }).ToList();
            }
        }
Exemplo n.º 2
0
        private static ConnectionFactory CreateFactory(RabbitMQOptions options)
        {
            ConnectionFactory factory = new ConnectionFactory()
            {
                HostName    = options.HostName,
                Port        = options.Port,
                UserName    = options.UserName,
                Password    = options.Password,
                VirtualHost = options.VirtualHost,
                //  ClientProvidedName = options.ClientProvidedName
            };

            if (!string.IsNullOrWhiteSpace(options.ClientProvidedName))
            {
                factory.ClientProvidedName = options.ClientProvidedName;
            }
            if (options.ConsumerDispatchConcurrency > 0)
            {
                factory.ConsumerDispatchConcurrency = options.ConsumerDispatchConcurrency;
            }
            return(factory);
        }