// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime applicationLifetime, IConsulClient client, IStartupInitializer startupInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseAllForwardedHeaders(); app.UseSwaggerDocs(); app.UseErrorHandler(); app.UseServiceId(); #pragma warning disable MVC1005 app.UseMvc(); #pragma warning restore MVC1005 app.UseRabbitMq() .SubscribeCommand <CreateProduct>(onError: (c, e) => new CreateProductRejected(c.Id, e.Message, e.Code)) .SubscribeCommand <UpdateProduct>(onError: (c, e) => new UpdateProductRejected(c.Id, e.Message, e.Code)) .SubscribeCommand <DeleteProduct>(onError: (c, e) => new DeleteProductRejected(c.Id, e.Message, e.Code)) .SubscribeCommand <ReserveProducts>(onError: (c, e) => new ReserveProductsRejected(c.OrderId, e.Message, e.Code)) .SubscribeCommand <ReleaseProducts>(onError: (c, e) => new ReleaseProductsRejected(c.OrderId, e.Message, e.Code)); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); }); startupInitializer.InitializeAsync(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IConsulClient client, IStartupInitializer startupInitializer) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); } app.UseAllForwardedHeaders(); app.UseSwaggerDocs(); app.UseErrorHandler(); app.UseServiceId(); app.UseMvc(); app.UseRabbitMq() .SubscribeCommand <CreateConfiguration>(onError: (c, e) => new CreateConfigurationRejected(c.Id, e.Message, e.Code)); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); Container.Dispose(); }); startupInitializer.InitializeAsync(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IConsulClient client, IStartupInitializer startupInitializer) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); } app.UseAllForwardedHeaders(); app.UseSwaggerDocs(); app.UseErrorHandler(); app.UseServiceId(); app.UseMvc(); app.UseRabbitMq() .SubscribeCommand <SendEmailNotification>() .SubscribeEvent <OrderCreated>(@namespace: "orders"); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); Container.Dispose(); }); startupInitializer.InitializeAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IStartupInitializer startupInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseMvc(); app.UseRabbitMq() .SubscribeEvent <FriendAdded>(); applicationLifetime.ApplicationStopped.Register(() => { Container.Dispose(); }); startupInitializer.InitializeAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IStartupInitializer startupInitializer) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); } app.UseCors("CorsPolicy"); app.UseSwaggerDocs(); app.UseHttpsRedirection(); app.UseRouting(); app.UseApiExceptionHandler(); app.UseRabbitMq(); app.UseAuthentication(); startupInitializer.InitializeAsync(); app.UseMvc(); }
public void Configure(IApplicationBuilder app, IStartupInitializer startupInitializer, IConsulClient client, IHostApplicationLifetime applicationLifetime) { app.UseCors("CorsPolicy"); app.UseAllForwardedHeaders(); app.UseErrorHandler(); app.UseAuthentication(); app.UseServiceId(); // app.UseAccessTokenValidator(); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); }); app.UseRouting(); app.UseEndpoints(routes => { routes.MapControllers(); }); startupInitializer.InitializeAsync(); }
public void Configure(IApplicationBuilder app, IStartupInitializer startupInitializer, IConsulClient client, IHostApplicationLifetime applicationLifetime) { app.UseHttpsRedirection(); app.UseRabbitMq(); app.UseAllForwardedHeaders(); app.UseServiceId(); app.UseAuthentication(); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); }); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(routes => { routes.MapControllers(); }); startupInitializer.InitializeAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IStartupInitializer startupInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCustomExceptionHandler(); app.UseCustomResponseHandler(); app.UseCors("CorsPolicy"); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); startupInitializer.InitializeAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime applicationLifetime, IConsulClient client, IStartupInitializer startupInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors("CorsPolicy"); app.UseAllForwardedHeaders(); app.UseSwaggerDocs(); app.UseErrorHandler(); app.UseAuthentication(); app.UseAccessTokenValidator(); app.UseServiceId(); #pragma warning disable MVC1005 app.UseMvc(); #pragma warning restore MVC1005 app.UseRabbitMq().SubscribeEvent <IRejectedEvent>(onError: (ee, e) => { return(null); }); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); }); startupInitializer.InitializeAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IStartupInitializer startupInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors("CorsPolicy"); app.UseAllForwardedHeaders(); app.UseSwaggerDocs(); app.UseErrorHandler(); app.UseRabbitMq() .SubscribeCommand <AddProduct>(onError: (c, e) => new AddProductRejected(c.Id, e.Message, e.Code)) .SubscribeCommand <AddProductCategory>(onError: (c, e) => new AddProductCategoryRejected(c.Id, e.Message, e.Code)); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); startupInitializer.InitializeAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IStartupInitializer initializer, IApplicationLifetime applicationLifetime, IConsulClient client) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } initializer.InitializeAsync(); app.UseRabbitMq() .SubscribeCommand <CreateCustomer>(onError: (c, e) => new CreateCustomerRejected(c.Id, e.Message, e.Code)); app.UseHttpsRedirection(); app.UseMvc(); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); Container.Dispose(); }); }
public void Configure( IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime applicationLifetime, IStartupInitializer startupInitializer, IConsulClient client) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseErrorHandler(); app.UseHttpsRedirection(); app.UseRouting(); app.UseAuthorization(); app.UseServiceId(); app.UseRabbitMq().SubscribeAllMessages(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); Container.Dispose(); }); startupInitializer.InitializeAsync(); }
public static IApplicationBuilder UseInfrastructure(this IApplicationBuilder app) { IHostApplicationLifetime applicationLifetime = app.ApplicationServices.GetService <IHostApplicationLifetime>(); IConsulClient client = app.ApplicationServices.GetService <IConsulClient>(); IStartupInitializer startupInitializer = app.ApplicationServices.GetService <IStartupInitializer>(); app.UseErrorHandler() .UseJaeger() .UseAppMetrics() .UseRabbitMq() .SubscribeCommand <AddGameEventSource>(onError: (c, e) => new AddGameEventSourceRejected(c.Id, e.Message, e.Code)); // .SubscribeCommand<UpdateGameEventSource>(onError: (c, e) => // new UpdateGameEventSourceRejected(c.Id, e.Message, e.Code)) // .SubscribeCommand<DeleteGameEventSource>(onError: (c, e) => // new DeleteGameEventSourceRejected(c.Id, e.Message, e.Code)) var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); }); return(app); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IStartupInitializer startupInitializer) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); } app.UseCors("CorsPolicy"); app.UseSwaggerDocs(); app.UseHttpsRedirection(); app.UseRouting(); app.UseApiExceptionHandler(); app.UseRabbitMq() .SubscribeCommand <SignedUpCommand>(_namespace: "identityservice") .SubscribeCommand <ChangedPasswordCommand>(_namespace: "identityservice"); app.UseAuthentication(); startupInitializer.InitializeAsync(); app.UseMvc(); }
public void Configure(IApplicationBuilder app, IStartupInitializer startupInitializer, IConsulClient client, IHostApplicationLifetime applicationLifetime) { app.UseCors("CorsPolicy"); app.UseAllForwardedHeaders(); app.UseHttpsRedirection(); app.UseErrorHandler(); app.UseServiceId(); app.UseRabbitMq().SubscribeCommand <CreateProduct>(); app.SeedProductsAsync(); app.UseRouting(); app.UseEndpoints(routes => { routes.MapControllers(); }); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); }); startupInitializer.InitializeAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IApiVersionDescriptionProvider provider, IHostApplicationLifetime applicationLifetime, IStartupInitializer initializer, IConsulClient consulClient) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } // app.UseHttpsRedirection(); //app.UseCors(builder => builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); initializer.InitializeAsync(); app.UseRouting(); // app.UseAuthorization(); // app.UseMvc(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); app.UseSwaggerBuilder(provider); var serviceId = app.UseConsul(); // Disposing container when application getting stopped. applicationLifetime.ApplicationStopped.Register(() => { // Once app becomes offline then remove it from consul. Otherwise it will remain in consul service registry // as dead service consulClient.Agent.ServiceDeregister(serviceId); Container.Dispose(); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IConsulClient client, IStartupInitializer startupInitializer) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); } app.UseCors("CorsPolicy"); app.UseAllForwardedHeaders(); app.UseSwaggerDocs(); app.UseErrorHandler(); app.UseAuthentication(); app.UseAccessTokenValidator(); app.UseServiceId(); app.UseMvc(); app.UseRabbitMq(); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); Container.Dispose(); }); startupInitializer.InitializeAsync(); }
public static IApplicationBuilder UseInfrastructure(this IApplicationBuilder app) { IHostApplicationLifetime applicationLifetime = app.ApplicationServices.GetService <IHostApplicationLifetime>(); IConsulClient client = app.ApplicationServices.GetService <IConsulClient>(); IStartupInitializer startupInitializer = app.ApplicationServices.GetService <IStartupInitializer>(); app.UseErrorHandler() .UseJaeger() .UseAppMetrics() .UseRabbitMQ().SubscribeEvent <GameEventSourceAdded>(); return(app); }
public async void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime applicationLifetime, IStartupInitializer initializer, IConsulClient consulClient, IRecordDbInitialiser dbInitialiser) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); // Initialise the database try { if (Configuration.GetValue <string>("database:seed").ToLowerInvariant() == "true") { dbInitialiser.Initialise(); } } catch (Exception) { //Log.Error("Error, {Name}", ex.ToString(), LogEventLevel.Error); } } app.UseMvc(); app.UseAllForwardedHeaders(); app.UseSwaggerDocs(); app.UseErrorHandler(); app.UseAuthentication(); app.UseAccessTokenValidator(); app.UseServiceId(); app.UseRabbitMq() .SubscribeCommand <CreateRuleCommand>() .SubscribeCommand <UpdateRuleCommand>() .SubscribeCommand <DeleteRuleCommand>() .SubscribeCommand <CreateStudentScoreCommand>() .SubscribeCommand <UpdateStudentScoreCommand>() .SubscribeCommand <DeleteStudentScoreCommand>() //.SubscribeCommand<CreateClassSubjectScoresCommand>() //.SubscribeCommand<UpdateClassSubjectScoresCommand>() //.SubscribeCommand<DeleteClassSubjectScoresCommand>() ; var serviceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { consulClient.Agent.ServiceDeregister(serviceId); //Container.Dispose(); }); await initializer.InitializeAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IStartupInitializer initializer) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); } initializer.InitializeAsync(); app.UseMvc(); app.UseRabbitMq().SubscribeCommand <CreateFederation>(); app.UseSwaggerDocs(); applicationLifetime.ApplicationStopped.Register(() => Container.Dispose()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IStartupInitializer startupInitializer, IApplicationLifetime applicationLifetime) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseCors("CorsPolicy"); app.UseAllForwardedHeaders(); app.UseErrorHandler(); app.UseAuthentication(); app.UseMvc(); app.UseLogging(); startupInitializer.InitializeAsync(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IStartupInitializer startupInitializer) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); } app.UseErrorHandler(); app.UseServiceId(); app.UseSwaggerDocs(); app.UseMvc(); applicationLifetime.ApplicationStopped.Register(() => { Container.Dispose(); }); startupInitializer.InitializeAsync(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IStartupInitializer initializer) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); } initializer.InitializeAsync(); app.UseMvc(); app.UseRabbitMq() .SubscribeCommand <CreateDiscount>() .SubscribeEvent <CustomerCreated>(); //To Do: Why below code not working for discount service //applicationLifetime.ApplicationStarted.Register(() => Container.Dispose()); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IStartupInitializer startupInitializer, IApplicationLifetime applicationLifetime) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseSwaggerDocs(); app.UseHttpsRedirection(); app.UseErrorHandler(); app.UseMvc(); app.UseRabbitMq(); applicationLifetime.ApplicationStopped.Register(() => { Container.Dispose(); }); startupInitializer.InitializeAsync(); }
public static IApplicationBuilder UseInfrastructure(this IApplicationBuilder app) { IHostApplicationLifetime applicationLifetime = app.ApplicationServices.GetService <IHostApplicationLifetime>(); IConsulClient client = app.ApplicationServices.GetService <IConsulClient>(); IStartupInitializer startupInitializer = app.ApplicationServices.GetService <IStartupInitializer>(); app.UseErrorHandler() .UseJaeger() .UseAppMetrics() .UseRabbitMq().SubscribeEvent <GameEventSourceAdded>(); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); }); return(app); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IStartupInitializer startupInitializer) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseMvc() .UseAuthentication() .UseAccessTokenValidator(); startupInitializer.InitializeAsync(); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, IStartupInitializer initializer, IApplicationLifetime applicationLifetime, IConsulClient client) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseMvc(); initializer.InitializeAsync(); app.UseRabbitMq() .SubscribeCommand <CreateCategory>(); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); Container.Dispose(); }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IConsulClient client, IStartupInitializer startupInitializer) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); } app.UseAllForwardedHeaders(); app.UseSwaggerDocs(); app.UseErrorHandler(); app.UseServiceId(); app.UseMvc(); app.UseRabbitMq() .SubscribeCommand <CreateCustomer>(onError: (c, e) => new CreateCustomerRejected(c.Id, e.Message, e.Code)) .SubscribeCommand <AddProductToCart>(onError: (c, e) => new AddProductToCartRejected(c.CustomerId, c.ProductId, c.Quantity, e.Message, e.Code)) .SubscribeCommand <DeleteProductFromCart>(onError: (c, e) => new DeleteProductFromCartRejected(c.CustomerId, c.ProductId, e.Message, e.Code)) .SubscribeCommand <ClearCart>(onError: (c, e) => new ClearCartRejected(c.CustomerId, e.Message, e.Code)) .SubscribeEvent <SignedUp>(@namespace: "identity") .SubscribeEvent <ProductCreated>(@namespace: "products") .SubscribeEvent <ProductUpdated>(@namespace: "products") .SubscribeEvent <ProductDeleted>(@namespace: "products") .SubscribeEvent <OrderApproved>(@namespace: "orders") .SubscribeEvent <OrderCompleted>(@namespace: "orders") .SubscribeEvent <OrderCanceled>(@namespace: "orders"); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); Container.Dispose(); }); startupInitializer.InitializeAsync(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IConsulClient client, IStartupInitializer startupInitializer) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); } app.UseAllForwardedHeaders(); app.UseSwaggerDocs(); app.UseErrorHandler(); app.UseServiceId(); app.UseMvc(); app.UseRabbitMq() .SubscribeCommand <CreateOrder>(onError: (c, e) => new CreateOrderRejected(c.Id, c.CustomerId, e.Message, e.Code)) .SubscribeCommand <ApproveOrder>(onError: (c, e) => new ApproveOrderRejected(c.Id, e.Message, e.Code)) .SubscribeCommand <CancelOrder>(onError: (c, e) => new CancelOrderRejected(c.Id, c.CustomerId, e.Message, e.Code)) .SubscribeCommand <RevokeOrder>(onError: (c, e) => new RevokeOrderRejected(c.Id, c.CustomerId, e.Message, e.Code)) .SubscribeCommand <CompleteOrder>(onError: (c, e) => new CompleteOrderRejected(c.Id, c.CustomerId, e.Message, e.Code)) .SubscribeCommand <CreateOrderDiscount>() .SubscribeEvent <CustomerCreated>(@namespace: "customers") .SubscribeEvent <DiscountCreated>(); var consulServiceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { client.Agent.ServiceDeregister(consulServiceId); Container.Dispose(); }); startupInitializer.InitializeAsync(); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime applicationLifetime, IStartupInitializer initializer, IConsulClient consulClient) { if (env.IsDevelopment() || env.EnvironmentName == "local") { app.UseDeveloperExceptionPage(); } initializer.InitializeAsync(); app.UseMvc(); //app.UseRabbitMq() // .SubscribeCommand<CreateReasonCode>(onError: (cmd, ex) => new CreateReasonCodeRejected(cmd.Code, ex.Message)) // .SubscribeEvent<ReasonCodeCreated>(@namespace: "reason-code"); var serviceId = app.UseConsul(); applicationLifetime.ApplicationStopped.Register(() => { consulClient.Agent.ServiceDeregister(serviceId); Container.Dispose(); }); }