示例#1
0
        public static BrokerConfigConsumers GetBrokerConfigConfigConsumers(this IConfiguration configuration,
                                                                           string sectionName)
        {
            var section = configuration.GetSection(sectionName);

            byte.TryParse(section["TotalInstances"], out var totalInstances);
            bool.TryParse(section["ShuffleHostList"], out var shuffleHostList);

            bool.TryParse(section["UseTLS"], out var useTls);

            var conf = new BrokerConfigConsumers
            {
                Host                  = section["Host"],
                Port                  = Convert.ToInt16(section["Port"]),
                Password              = section["Password"],
                VirtualHost           = section["VirtualHost"],
                Username              = section["Username"],
                RoutingKeyOrQueueName = section["RoutingKeyOrQueueName"],
                TotalInstances        = totalInstances,
                ShuffleHostList       = shuffleHostList,
                UseTLS                = useTls
            };

            return(conf);
        }
示例#2
0
        private static IBrokerConfigConsumers GetBrokerConfigConsumers()
        {
            IBrokerConfigConsumers configConsumers = new BrokerConfigConsumers
            {
                Username              = "******",
                Password              = "******",
                Host                  = hostName,
                VirtualHost           = "/",
                RoutingKeyOrQueueName = "MyTestQueue",
                ShuffleHostList       = false,
                Port                  = 0,
                TotalInstances        = 255
            };

            return(configConsumers);
        }