public ConsumerConfiguration(ConsumerConfigurationSection config)
        {
            Validate(config);
            this.NumberOfTries         = config.NumberOfTries;
            this.GroupId               = config.GroupId;
            this.Timeout               = config.Timeout;
            this.AutoOffsetReset       = config.AutoOffsetReset;
            this.AutoCommit            = config.AutoCommit;
            this.AutoCommitInterval    = config.AutoCommitInterval;
            this.FetchSize             = config.FetchSize;
            this.BackOffIncrement      = config.BackOffIncrement;
            this.SocketTimeout         = config.SocketTimeout;
            this.BufferSize            = config.BufferSize;
            this.MaxQueuedChunks       = config.MaxQueuedChunks;
            this.IdleTimeToKeepAlive   = config.IdleTimeToKeepAlive;
            this.KeepAliveInterval     = config.KeepAliveInterval;
            this.SocketPollingTimeout  = config.SocketPollingTimeout;
            this.SocketPollingLevel    = config.SocketPollingLevel;
            this.MaxConnectionPoolSize = config.MaxConnectionPoolSize;
            this.ConnectionLifeSpan    = config.ConnectionLifeSpan;

            if (config.Broker.ElementInformation.IsPresent)
            {
                this.SetBrokerConfiguration(config.Broker);
            }
            else
            {
                this.SetZooKeeperConfiguration(config.ZooKeeperServers);
            }
        }
        public static ConsumerConfigurationSection FromXml(XElement element)
        {
            var section = new ConsumerConfigurationSection();

            section.DeserializeSection(element.CreateReader());
            return(section);
        }
 public ConsumerConfiguration(ConsumerConfigurationSection config)
 {
     Validate(config);
     NumberOfTries        = config.NumberOfTries;
     GroupId              = config.GroupId;
     Timeout              = config.Timeout;
     AutoOffsetReset      = config.AutoOffsetReset;
     AutoCommit           = config.AutoCommit;
     AutoCommitInterval   = config.AutoCommitInterval;
     FetchSize            = config.FetchSize;
     BackOffIncrement     = config.BackOffIncrement;
     SendTimeout          = config.SendTimeout;
     ReceiveTimeout       = config.ReceiveTimeout;
     BufferSize           = config.BufferSize;
     ConsumerId           = config.ConsumerId;
     ShutdownTimeout      = config.ShutdownTimeout;
     MaxFetchBufferLength = config.MaxFetchBufferLength;
     ConsumeGroupRebalanceRetryIntervalMs     = DefaultConsumeGroupRebalanceRetryIntervalMs;
     ConsumeGroupFindNewLeaderSleepIntervalMs = DefaultConsumeGroupFindNewLeaderSleepIntervalMs;
     if (config.Broker.ElementInformation.IsPresent)
     {
         SetBrokerConfiguration(config.Broker);
     }
     else
     {
         SetZooKeeperConfiguration(config.ZooKeeperServers);
     }
 }
        private static void Validate(ConsumerConfigurationSection config)
        {
            if (config.Broker.ElementInformation.IsPresent &&
                config.ZooKeeperServers.ElementInformation.IsPresent)
            {
                throw new ConfigurationErrorsException("ZooKeeper configuration cannot be set when brokers configuration is used");
            }

            if (!config.ZooKeeperServers.ElementInformation.IsPresent &&
                !config.Broker.ElementInformation.IsPresent)
            {
                throw new ConfigurationErrorsException("ZooKeeper server or Kafka broker configuration must be set");
            }

            if (config.ZooKeeperServers.ElementInformation.IsPresent &&
                config.ZooKeeperServers.Servers.Count == 0)
            {
                throw new ConfigurationErrorsException("At least one ZooKeeper server address is required");
            }
        }
 public ConsumerConfiguration(XElement xmlElement)
     : this(ConsumerConfigurationSection.FromXml(xmlElement))
 {
 }
 public static ConsumerConfigurationSection FromXml(XElement element)
 {
     var section = new ConsumerConfigurationSection();
     section.DeserializeSection(element.CreateReader());
     return section;
 }
        private static void Validate(ConsumerConfigurationSection config)
        {
            if (config.Broker.ElementInformation.IsPresent
                && config.ZooKeeperServers.ElementInformation.IsPresent)
            {
                throw new ConfigurationErrorsException("ZooKeeper configuration cannot be set when brokers configuration is used");
            }

            if (!config.ZooKeeperServers.ElementInformation.IsPresent
                && !config.Broker.ElementInformation.IsPresent)
            {
                throw new ConfigurationErrorsException("ZooKeeper server or Kafka broker configuration must be set");
            }

            if (config.ZooKeeperServers.ElementInformation.IsPresent
                && config.ZooKeeperServers.Servers.Count == 0)
            {
                throw new ConfigurationErrorsException("At least one ZooKeeper server address is required");
            }
        }
 public ConsumerConfiguration(ConsumerConfigurationSection config)
 {
     Validate(config);
     this.NumberOfTries = config.NumberOfTries;
     this.GroupId = config.GroupId;
     this.Timeout = config.Timeout;
     this.AutoOffsetReset = config.AutoOffsetReset;
     this.AutoCommit = config.AutoCommit;
     this.AutoCommitInterval = config.AutoCommitInterval;
     this.FetchSize = config.FetchSize;
     this.BackOffIncrement = config.BackOffIncrement;
     this.SendTimeout = config.SendTimeout;
     this.ReceiveTimeout = config.ReceiveTimeout;
     this.BufferSize = config.BufferSize;
     this.ConsumerId = config.ConsumerId;
     this.ShutdownTimeout = config.ShutdownTimeout;
     this.MaxFetchBufferLength = config.MaxFetchBufferLength;
     this.ConsumeGroupRebalanceRetryIntervalMs = DefaultConsumeGroupRebalanceRetryIntervalMs;
     this.ConsumeGroupFindNewLeaderSleepIntervalMs = DefaultConsumeGroupFindNewLeaderSleepIntervalMs;
     if (config.Broker.ElementInformation.IsPresent)
     {
         this.SetBrokerConfiguration(config.Broker);
     }
     else
     {
         this.SetZooKeeperConfiguration(config.ZooKeeperServers);
     }
 }