Migrate all dockerfiles to use 2.1 image. Added ApiBehaviorOptions into Catalog
This commit is contained in:
parent
d1b6bc84fa
commit
b02c1b825d
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY src/ApiGateways/ApiGw-Base/OcelotApiGw.csproj src/ApiGateways/ApiGw-Base/
|
||||
RUN dotnet restore src/ApiGateways/ApiGw-Base/
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -15,6 +15,7 @@ using System.Threading.Tasks;
|
||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
||||
{
|
||||
[Route("api/v1/[controller]")]
|
||||
[ApiController]
|
||||
public class CatalogController : ControllerBase
|
||||
{
|
||||
private readonly CatalogContext _catalogContext;
|
||||
@ -25,8 +26,8 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
||||
{
|
||||
_catalogContext = context ?? throw new ArgumentNullException(nameof(context));
|
||||
_catalogIntegrationEventService = catalogIntegrationEventService ?? throw new ArgumentNullException(nameof(catalogIntegrationEventService));
|
||||
|
||||
_settings = settings.Value;
|
||||
|
||||
((DbContext)context).ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -1,35 +1,37 @@
|
||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API
|
||||
{
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using global::Catalog.API.Infrastructure.Filters;
|
||||
using global::Catalog.API.IntegrationEvents;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Microsoft.ApplicationInsights.ServiceFabric;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.Azure.ServiceBus;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
||||
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
||||
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling;
|
||||
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.HealthChecks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using RabbitMQ.Client;
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Reflection;
|
||||
using Autofac;
|
||||
using Autofac.Extensions.DependencyInjection;
|
||||
using global::Catalog.API.Infrastructure.Filters;
|
||||
using global::Catalog.API.IntegrationEvents;
|
||||
using Microsoft.ApplicationInsights.Extensibility;
|
||||
using Microsoft.ApplicationInsights.ServiceFabric;
|
||||
using Microsoft.AspNetCore.Builder;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Azure.ServiceBus;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Diagnostics;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBus.Abstractions;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusRabbitMQ;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.EventBusServiceBus;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF;
|
||||
using Microsoft.eShopOnContainers.BuildingBlocks.IntegrationEventLogEF.Services;
|
||||
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
|
||||
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.EventHandling;
|
||||
using Microsoft.eShopOnContainers.Services.Catalog.API.IntegrationEvents.Events;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.HealthChecks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using RabbitMQ.Client;
|
||||
using System;
|
||||
using System.Data.Common;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API
|
||||
{
|
||||
public class Startup
|
||||
{
|
||||
public Startup(IConfiguration configuration)
|
||||
@ -41,133 +43,12 @@
|
||||
|
||||
public IServiceProvider ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
// Add framework services.
|
||||
|
||||
RegisterAppInsights(services);
|
||||
|
||||
services.AddHealthChecks(checks =>
|
||||
{
|
||||
var minutes = 1;
|
||||
if (int.TryParse(Configuration["HealthCheck:Timeout"], out var minutesParsed))
|
||||
{
|
||||
minutes = minutesParsed;
|
||||
}
|
||||
checks.AddSqlCheck("CatalogDb", Configuration["ConnectionString"], TimeSpan.FromMinutes(minutes));
|
||||
|
||||
var accountName = Configuration.GetValue<string>("AzureStorageAccountName");
|
||||
var accountKey = Configuration.GetValue<string>("AzureStorageAccountKey");
|
||||
if (!string.IsNullOrEmpty(accountName) && !string.IsNullOrEmpty(accountKey))
|
||||
{
|
||||
checks.AddAzureBlobStorageCheck(accountName, accountKey);
|
||||
}
|
||||
});
|
||||
|
||||
services.AddMvc(options =>
|
||||
{
|
||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
||||
}).AddControllersAsServices();
|
||||
|
||||
services.AddDbContext<CatalogContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(Configuration["ConnectionString"],
|
||||
sqlServerOptionsAction: sqlOptions =>
|
||||
{
|
||||
sqlOptions.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
|
||||
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
||||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 10, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
||||
});
|
||||
|
||||
// Changing default behavior when client evaluation occurs to throw.
|
||||
// Default in EF Core would be to log a warning when client evaluation is performed.
|
||||
options.ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning));
|
||||
//Check Client vs. Server evaluation: https://docs.microsoft.com/en-us/ef/core/querying/client-eval
|
||||
});
|
||||
|
||||
services.AddDbContext<IntegrationEventLogContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(Configuration["ConnectionString"],
|
||||
sqlServerOptionsAction: sqlOptions =>
|
||||
{
|
||||
sqlOptions.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
|
||||
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
||||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 10, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
||||
});
|
||||
});
|
||||
|
||||
services.Configure<CatalogSettings>(Configuration);
|
||||
|
||||
// Add framework services.
|
||||
services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.DescribeAllEnumsAsStrings();
|
||||
options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info
|
||||
{
|
||||
Title = "eShopOnContainers - Catalog HTTP API",
|
||||
Version = "v1",
|
||||
Description = "The Catalog Microservice HTTP API. This is a Data-Driven/CRUD microservice sample",
|
||||
TermsOfService = "Terms Of Service"
|
||||
});
|
||||
});
|
||||
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("CorsPolicy",
|
||||
builder => builder.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials());
|
||||
});
|
||||
|
||||
services.AddTransient<Func<DbConnection, IIntegrationEventLogService>>(
|
||||
sp => (DbConnection c) => new IntegrationEventLogService(c));
|
||||
|
||||
services.AddTransient<ICatalogIntegrationEventService, CatalogIntegrationEventService>();
|
||||
|
||||
if (Configuration.GetValue<bool>("AzureServiceBusEnabled"))
|
||||
{
|
||||
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
||||
{
|
||||
var settings = sp.GetRequiredService<IOptions<CatalogSettings>>().Value;
|
||||
var logger = sp.GetRequiredService<ILogger<DefaultServiceBusPersisterConnection>>();
|
||||
|
||||
var serviceBusConnection = new ServiceBusConnectionStringBuilder(settings.EventBusConnection);
|
||||
|
||||
return new DefaultServiceBusPersisterConnection(serviceBusConnection, logger);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddSingleton<IRabbitMQPersistentConnection>(sp =>
|
||||
{
|
||||
var settings = sp.GetRequiredService<IOptions<CatalogSettings>>().Value;
|
||||
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
|
||||
|
||||
var factory = new ConnectionFactory()
|
||||
{
|
||||
HostName = Configuration["EventBusConnection"]
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(Configuration["EventBusUserName"]))
|
||||
{
|
||||
factory.UserName = Configuration["EventBusUserName"];
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(Configuration["EventBusPassword"]))
|
||||
{
|
||||
factory.Password = Configuration["EventBusPassword"];
|
||||
}
|
||||
|
||||
var retryCount = 5;
|
||||
if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"]))
|
||||
{
|
||||
retryCount = int.Parse(Configuration["EventBusRetryCount"]);
|
||||
}
|
||||
|
||||
return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount);
|
||||
});
|
||||
}
|
||||
|
||||
RegisterEventBus(services);
|
||||
services.AddAppInsight(Configuration)
|
||||
.AddCustomMVC(Configuration)
|
||||
.AddCustomDbContext(Configuration)
|
||||
.AddCustomOptions(Configuration)
|
||||
.AddEventBus(Configuration)
|
||||
.AddSwagger();
|
||||
|
||||
var container = new ContainerBuilder();
|
||||
container.Populate(services);
|
||||
@ -179,12 +60,11 @@
|
||||
{
|
||||
//Configure logs
|
||||
|
||||
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||
loggerFactory.AddDebug();
|
||||
loggerFactory.AddAzureWebAppDiagnostics();
|
||||
loggerFactory.AddApplicationInsights(app.ApplicationServices, LogLevel.Trace);
|
||||
|
||||
var pathBase = Configuration["PATH_BASE"];
|
||||
|
||||
if (!string.IsNullOrEmpty(pathBase))
|
||||
{
|
||||
loggerFactory.CreateLogger("init").LogDebug($"Using PATH BASE '{pathBase}'");
|
||||
@ -208,10 +88,20 @@
|
||||
ConfigureEventBus(app);
|
||||
}
|
||||
|
||||
private void RegisterAppInsights(IServiceCollection services)
|
||||
protected virtual void ConfigureEventBus(IApplicationBuilder app)
|
||||
{
|
||||
services.AddApplicationInsightsTelemetry(Configuration);
|
||||
var orchestratorType = Configuration.GetValue<string>("OrchestratorType");
|
||||
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
|
||||
eventBus.Subscribe<OrderStatusChangedToAwaitingValidationIntegrationEvent, OrderStatusChangedToAwaitingValidationIntegrationEventHandler>();
|
||||
eventBus.Subscribe<OrderStatusChangedToPaidIntegrationEvent, OrderStatusChangedToPaidIntegrationEventHandler>();
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomExtensionMethods
|
||||
{
|
||||
public static IServiceCollection AddAppInsight(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddApplicationInsightsTelemetry(configuration);
|
||||
var orchestratorType = configuration.GetValue<string>("OrchestratorType");
|
||||
|
||||
if (orchestratorType?.ToUpper() == "K8S")
|
||||
{
|
||||
@ -224,13 +114,179 @@
|
||||
services.AddSingleton<ITelemetryInitializer>((serviceProvider) =>
|
||||
new FabricTelemetryInitializer());
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
private void RegisterEventBus(IServiceCollection services)
|
||||
public static IServiceCollection AddCustomMVC(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var subscriptionClientName = Configuration["SubscriptionClientName"];
|
||||
services.AddHealthChecks(checks =>
|
||||
{
|
||||
var minutes = 1;
|
||||
if (int.TryParse(configuration["HealthCheck:Timeout"], out var minutesParsed))
|
||||
{
|
||||
minutes = minutesParsed;
|
||||
}
|
||||
checks.AddSqlCheck("CatalogDb", configuration["ConnectionString"], TimeSpan.FromMinutes(minutes));
|
||||
|
||||
if (Configuration.GetValue<bool>("AzureServiceBusEnabled"))
|
||||
var accountName = configuration.GetValue<string>("AzureStorageAccountName");
|
||||
var accountKey = configuration.GetValue<string>("AzureStorageAccountKey");
|
||||
if (!string.IsNullOrEmpty(accountName) && !string.IsNullOrEmpty(accountKey))
|
||||
{
|
||||
checks.AddAzureBlobStorageCheck(accountName, accountKey);
|
||||
}
|
||||
});
|
||||
|
||||
services.AddMvc(options =>
|
||||
{
|
||||
options.Filters.Add(typeof(HttpGlobalExceptionFilter));
|
||||
}).AddControllersAsServices();
|
||||
|
||||
services.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy("CorsPolicy",
|
||||
builder => builder.AllowAnyOrigin()
|
||||
.AllowAnyMethod()
|
||||
.AllowAnyHeader()
|
||||
.AllowCredentials());
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddCustomDbContext(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddDbContext<CatalogContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(configuration["ConnectionString"],
|
||||
sqlServerOptionsAction: sqlOptions =>
|
||||
{
|
||||
sqlOptions.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
|
||||
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
||||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 10, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
||||
});
|
||||
|
||||
// Changing default behavior when client evaluation occurs to throw.
|
||||
// Default in EF Core would be to log a warning when client evaluation is performed.
|
||||
options.ConfigureWarnings(warnings => warnings.Throw(RelationalEventId.QueryClientEvaluationWarning));
|
||||
//Check Client vs. Server evaluation: https://docs.microsoft.com/en-us/ef/core/querying/client-eval
|
||||
});
|
||||
|
||||
services.AddDbContext<IntegrationEventLogContext>(options =>
|
||||
{
|
||||
options.UseSqlServer(configuration["ConnectionString"],
|
||||
sqlServerOptionsAction: sqlOptions =>
|
||||
{
|
||||
sqlOptions.MigrationsAssembly(typeof(Startup).GetTypeInfo().Assembly.GetName().Name);
|
||||
//Configuring Connection Resiliency: https://docs.microsoft.com/en-us/ef/core/miscellaneous/connection-resiliency
|
||||
sqlOptions.EnableRetryOnFailure(maxRetryCount: 10, maxRetryDelay: TimeSpan.FromSeconds(30), errorNumbersToAdd: null);
|
||||
});
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddCustomOptions(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.Configure<CatalogSettings>(configuration);
|
||||
services.Configure<ApiBehaviorOptions>(options =>
|
||||
{
|
||||
options.InvalidModelStateResponseFactory = context =>
|
||||
{
|
||||
var problemDetails = new ValidationProblemDetails(context.ModelState)
|
||||
{
|
||||
Instance = context.HttpContext.Request.Path,
|
||||
Status = StatusCodes.Status400BadRequest,
|
||||
Detail = "Please refer to the errors property for additional details."
|
||||
};
|
||||
|
||||
return new BadRequestObjectResult(problemDetails)
|
||||
{
|
||||
ContentTypes = { "application/problem+json", "application/problem+xml" }
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddSwagger(this IServiceCollection services)
|
||||
{
|
||||
services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.DescribeAllEnumsAsStrings();
|
||||
options.SwaggerDoc("v1", new Swashbuckle.AspNetCore.Swagger.Info
|
||||
{
|
||||
Title = "eShopOnContainers - Catalog HTTP API",
|
||||
Version = "v1",
|
||||
Description = "The Catalog Microservice HTTP API. This is a Data-Driven/CRUD microservice sample",
|
||||
TermsOfService = "Terms Of Service"
|
||||
});
|
||||
});
|
||||
|
||||
return services;
|
||||
|
||||
}
|
||||
|
||||
public static IServiceCollection AddIntegrationServices(IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
services.AddTransient<Func<DbConnection, IIntegrationEventLogService>>(
|
||||
sp => (DbConnection c) => new IntegrationEventLogService(c));
|
||||
|
||||
services.AddTransient<ICatalogIntegrationEventService, CatalogIntegrationEventService>();
|
||||
|
||||
if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
|
||||
{
|
||||
services.AddSingleton<IServiceBusPersisterConnection>(sp =>
|
||||
{
|
||||
var settings = sp.GetRequiredService<IOptions<CatalogSettings>>().Value;
|
||||
var logger = sp.GetRequiredService<ILogger<DefaultServiceBusPersisterConnection>>();
|
||||
|
||||
var serviceBusConnection = new ServiceBusConnectionStringBuilder(settings.EventBusConnection);
|
||||
|
||||
return new DefaultServiceBusPersisterConnection(serviceBusConnection, logger);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
services.AddSingleton<IRabbitMQPersistentConnection>(sp =>
|
||||
{
|
||||
var settings = sp.GetRequiredService<IOptions<CatalogSettings>>().Value;
|
||||
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
|
||||
|
||||
var factory = new ConnectionFactory()
|
||||
{
|
||||
HostName = configuration["EventBusConnection"]
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(configuration["EventBusUserName"]))
|
||||
{
|
||||
factory.UserName = configuration["EventBusUserName"];
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(configuration["EventBusPassword"]))
|
||||
{
|
||||
factory.Password = configuration["EventBusPassword"];
|
||||
}
|
||||
|
||||
var retryCount = 5;
|
||||
if (!string.IsNullOrEmpty(configuration["EventBusRetryCount"]))
|
||||
{
|
||||
retryCount = int.Parse(configuration["EventBusRetryCount"]);
|
||||
}
|
||||
|
||||
return new DefaultRabbitMQPersistentConnection(factory, logger, retryCount);
|
||||
});
|
||||
}
|
||||
|
||||
return services;
|
||||
}
|
||||
|
||||
public static IServiceCollection AddEventBus(this IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
var subscriptionClientName = configuration["SubscriptionClientName"];
|
||||
|
||||
if (configuration.GetValue<bool>("AzureServiceBusEnabled"))
|
||||
{
|
||||
services.AddSingleton<IEventBus, EventBusServiceBus>(sp =>
|
||||
{
|
||||
@ -254,9 +310,9 @@
|
||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||
|
||||
var retryCount = 5;
|
||||
if (!string.IsNullOrEmpty(Configuration["EventBusRetryCount"]))
|
||||
if (!string.IsNullOrEmpty(configuration["EventBusRetryCount"]))
|
||||
{
|
||||
retryCount = int.Parse(Configuration["EventBusRetryCount"]);
|
||||
retryCount = int.Parse(configuration["EventBusRetryCount"]);
|
||||
}
|
||||
|
||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
||||
@ -266,12 +322,8 @@
|
||||
services.AddSingleton<IEventBusSubscriptionsManager, InMemoryEventBusSubscriptionsManager>();
|
||||
services.AddTransient<OrderStatusChangedToAwaitingValidationIntegrationEventHandler>();
|
||||
services.AddTransient<OrderStatusChangedToPaidIntegrationEventHandler>();
|
||||
}
|
||||
protected virtual void ConfigureEventBus(IApplicationBuilder app)
|
||||
{
|
||||
var eventBus = app.ApplicationServices.GetRequiredService<IEventBus>();
|
||||
eventBus.Subscribe<OrderStatusChangedToAwaitingValidationIntegrationEvent, OrderStatusChangedToAwaitingValidationIntegrationEventHandler>();
|
||||
eventBus.Subscribe<OrderStatusChangedToPaidIntegrationEvent, OrderStatusChangedToPaidIntegrationEventHandler>();
|
||||
|
||||
return services;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY eShopOnContainers-ServicesAndWebApps.sln ./
|
||||
COPY src/Services/Ordering/Ordering.SignalrHub/Ordering.SignalrHub.csproj src/Services/Ordering/Ordering.SignalrHub/
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
@ -1,8 +1,8 @@
|
||||
FROM microsoft/aspnetcore:2.0.5 AS base
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS base
|
||||
WORKDIR /app
|
||||
EXPOSE 80
|
||||
|
||||
FROM microsoft/aspnetcore-build:2.0.5-2.1.4 AS build
|
||||
FROM microsoft/dotnet:2.1-sdk AS build
|
||||
WORKDIR /src
|
||||
COPY . .
|
||||
RUN dotnet restore -nowarn:msb3202,nu1503
|
||||
|
Loading…
x
Reference in New Issue
Block a user