public KafkaConnectionFactory(ConnectionConfiguration connectionConfiguration) { if (connectionConfiguration == null) { throw new ArgumentNullException("connectionConfiguration"); } if (connectionConfiguration.HostConfiguration == null) { throw new ArgumentException( "The connectionConfiguration has a null HostConfiguration.", "connectionConfiguration"); } Configuration = connectionConfiguration; //connectionFactory = new ConnectionFactory //{ // HostName = connectionConfiguration.HostConfiguration.Host, // Port = connectionConfiguration.HostConfiguration.Port, // VirtualHost = Configuration.VirtualHost, // UserName = Configuration.UserName, // Password = Configuration.Password, // RequestedHeartbeat = Configuration.RequestedHeartbeat, // ClientProperties = Configuration.ClientProperties //}; }
public ConnectionConfiguration Parse(string connectionString) { ConnectionString = connectionString; connectionConfiguration = new ConnectionConfiguration(); foreach (var pair in (from property in typeof(ConnectionConfiguration).GetProperties() let match = Regex.Match(connectionString, string.Format("[^\\w]*{0}=(?<{0}>[^;]+)", property.Name), RegexOptions.IgnoreCase) where match.Success select new { Property = property, match.Groups[property.Name].Value })) pair.Property.SetValue(connectionConfiguration, TypeDescriptor.GetConverter(pair.Property.PropertyType).ConvertFromString(pair.Value), null); if (ContainsKey("host")) { connectionConfiguration.ParseHosts(this["host"] as string); } if (settings.HasSetting("Endpoint.DurableMessages")) { connectionConfiguration.UsePublisherConfirms = settings.GetOrDefault<bool>("Endpoint.DurableMessages"); } connectionConfiguration.ClientProperties["endpoint_name"] = settings.GetOrDefault<string>("EndpointName"); connectionConfiguration.Validate(); return connectionConfiguration; }