private KafkaListenerConfiguration CreateConsumerConfiguration(KafkaTriggerAttribute attribute) { var consumerConfig = new KafkaListenerConfiguration() { BrokerList = this.config.ResolveSecureSetting(nameResolver, attribute.BrokerList), ConsumerGroup = this.nameResolver.ResolveWholeString(attribute.ConsumerGroup), Topic = this.nameResolver.ResolveWholeString(attribute.Topic), EventHubConnectionString = this.config.ResolveSecureSetting(nameResolver, attribute.EventHubConnectionString), }; if (attribute.AuthenticationMode != BrokerAuthenticationMode.NotSet || attribute.Protocol != BrokerProtocol.NotSet) { consumerConfig.SaslPassword = this.config.ResolveSecureSetting(nameResolver, attribute.Password); consumerConfig.SaslUsername = this.config.ResolveSecureSetting(nameResolver, attribute.Username); consumerConfig.SslKeyLocation = this.config.ResolveSecureSetting(nameResolver, attribute.SslKeyLocation); consumerConfig.SslKeyPassword = this.config.ResolveSecureSetting(nameResolver, attribute.SslKeyPassword); consumerConfig.SslCertificateLocation = this.config.ResolveSecureSetting(nameResolver, attribute.SslCertificateLocation); consumerConfig.SslCaLocation = this.config.ResolveSecureSetting(nameResolver, attribute.SslCaLocation); if (attribute.AuthenticationMode != BrokerAuthenticationMode.NotSet) { consumerConfig.SaslMechanism = (SaslMechanism)attribute.AuthenticationMode; } if (attribute.Protocol != BrokerProtocol.NotSet) { consumerConfig.SecurityProtocol = (SecurityProtocol)attribute.Protocol; } } return(consumerConfig); }
public static IListener CreateFor(KafkaTriggerAttribute attribute, Type parameterType, ITriggeredFunctionExecutor executor, bool singleDispatch, KafkaOptions options, KafkaListenerConfiguration consumerKafkaConfiguration, ILogger logger) { var valueType = SerializationHelper.GetValueType(attribute.ValueType, attribute.AvroSchema, parameterType, out var avroSchema); var valueDeserializer = SerializationHelper.ResolveValueDeserializer(valueType, avroSchema); return((IListener)Activator.CreateInstance( typeof(KafkaListener <,>).MakeGenericType(attribute.KeyType ?? typeof(Ignore), valueType), new object[] { executor, singleDispatch, options, consumerKafkaConfiguration, valueDeserializer, logger })); }