public static IServiceCollection AddKafkaConsumer(this IServiceCollection serviceCollection, string brokers, string groupId, bool allowAutoCreateTopics = true, bool isAsync = true) { if (string.IsNullOrEmpty(brokers)) { throw new ArgumentNullException(nameof(brokers)); } var consumer = new KafkaConsumerConnection(brokers, groupId, allowAutoCreateTopics); serviceCollection.AddSingleton <IKafkaConsumerConnection>(factory => consumer); return(serviceCollection); }
public static IServiceCollection AddKafkaConsumer(this IServiceCollection serviceCollection, string brokers, string groupId, bool allowAutoCreateTopics = true) { if (string.IsNullOrEmpty(brokers)) { throw new ArgumentNullException(nameof(brokers)); } var consumer = new KafkaConsumerConnection(brokers, groupId); consumer.Config.AllowAutoCreateTopics = allowAutoCreateTopics; serviceCollection.AddSingleton <IKafkaConsumerConnection>(factory => consumer); // serviceCollection.AddSingleton<IEventBusDispatcher, KafkaEventBusDispatcher>(); return(serviceCollection); }