// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // However, this was commented out for a brute forced approach to tying events together // via Configure(IApplicationBuilder app, IServiceProvider serviceProvider) // public void Configure(IApplicationBuilder app, IHostingEnvironment env) // { // if (env.IsDevelopment()) // { // app.UseDeveloperExceptionPage(); // } // // app.UseMvc(); // } // This method gets called by the runtime, but was manually introduced. // Use this method to configure injected services. public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider) { var env = serviceProvider.GetService <IHostingEnvironment>(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); var commandBus = serviceProvider.GetService <ICommandBus>() as FakeBus; if (commandBus != null) { var studyCommandHandlers = serviceProvider.GetService <StudyCommandHandlers>(); commandBus.RegisterCommandHandler <CreateStudyCommand>(studyCommandHandlers.Handle); commandBus.RegisterCommandHandler <ReviewStudyCommand>(studyCommandHandlers.Handle); } var queryBus = serviceProvider.GetService <IQueryBus>() as FakeBus; if (queryBus != null) { var studyQueryHandlers = serviceProvider.GetService <StudyQueryHandlers>(); queryBus.RegisterQueryHandler <GetAllStudiesQuery>(studyQueryHandlers.Handle); } string topicName = "studies"; string consumerGroupId = Guid.NewGuid().ToString(); // "studyApi"; var eventPublisher = serviceProvider.GetService <IEventPublisher>() as KafkaEventPublisher; eventPublisher.TopicName = topicName; _studyKafkaEventConsumer = serviceProvider.GetService <KafkaEventConsumer>(); _studyKafkaEventConsumer.TopicName = topicName; _studyKafkaEventConsumer.ConsumerGroupId = consumerGroupId; _kafkaConsumerTask = Task.Run(() => _studyKafkaEventConsumer.Start()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // However, this was commented out for a brute forced approach to tying events together // via Configure(IApplicationBuilder app, IServiceProvider serviceProvider) // public void Configure(IApplicationBuilder app, IHostingEnvironment env) // { // if (env.IsDevelopment()) // { // app.UseDeveloperExceptionPage(); // } // // app.UseMvc(); // } // This method gets called by the runtime, but was manually introduced. // Use this method to configure injected services. public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider) { var env = serviceProvider.GetService <IHostingEnvironment>(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); string topicName = "studies"; string consumerGroupId = "studyIssuesApi"; _studyKafkaEventConsumer = serviceProvider.GetService <KafkaEventConsumer>(); _studyKafkaEventConsumer.TopicName = topicName; _studyKafkaEventConsumer.ConsumerGroupId = consumerGroupId; var npqsqlTicketRepository = serviceProvider.GetService <ITicketRepository>() as NpgsqlTicketRepository; npqsqlTicketRepository.getDbContext = serviceProvider.GetService <TicketDbContext>; _kafkaConsumerTask = Task.Run(() => _studyKafkaEventConsumer.Start()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // However, this was commented out for a brute forced approach to tying events together // via Configure(IApplicationBuilder app, IServiceProvider serviceProvider) // public void Configure(IApplicationBuilder app, IHostingEnvironment env) // { // if (env.IsDevelopment()) // { // app.UseDeveloperExceptionPage(); // } // // app.UseMvc(); // } // This method gets called by the runtime, but was manually introduced. // Use this method to configure injected services. public void Configure(IApplicationBuilder app, IServiceProvider serviceProvider) { var env = serviceProvider.GetService <IHostingEnvironment>(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); string topicName = "studies"; string consumerGroupId = "studyValidationApi"; var eventPublisher = serviceProvider.GetService <IEventPublisher>() as KafkaEventPublisher; eventPublisher.TopicName = topicName; _studyKafkaEventConsumer = serviceProvider.GetService <KafkaEventConsumer>(); _studyKafkaEventConsumer.TopicName = topicName; _studyKafkaEventConsumer.ConsumerGroupId = consumerGroupId; _kafkaConsumerTask = Task.Run(() => _studyKafkaEventConsumer.Start()); }