예제 #1
0
        public static IServiceCollection AddSubscription(
            this IServiceCollection services,
            IConfiguration configuration)
        {
            const string groupId = "amethyst_querying";

            var kafkaBrokers     = configuration.GetSection("Kafka:Brokers").Get <string>();
            var consumerSettings = configuration.GetSection("CardsConsumer").Get <ConsumerSettings>();

            consumerSettings.Config.GroupId          = groupId;
            consumerSettings.Config.BootstrapServers = kafkaBrokers;

            var endpointConfig = new EndpointConfiguration();

            endpointConfig.AddSubscription(
                consumerSettings,
                new DomainEventDeserializer()
                );

            services.AddSubscriptions(
                endpointConfig,
                ServiceLifetime.Scoped,
                AppDomain.CurrentDomain.GetAssemblies());

            return(services);
        }