diff --git a/ExternalSystem/PaymentService/Controllers/PaymentController.cs b/ExternalSystem/PaymentService/Controllers/PaymentController.cs index 4482569..0385f75 100644 --- a/ExternalSystem/PaymentService/Controllers/PaymentController.cs +++ b/ExternalSystem/PaymentService/Controllers/PaymentController.cs @@ -8,8 +8,9 @@ namespace PaymentService.Controllers [Route("api/[controller]")] public class PaymentController : Controller { - private readonly List _paymentStatuses = new List { "Accepted", "Rejected" }; - private readonly List _cardTypes = new List { "Visa", "Master Card", "American Express" }; + public List CardTypes { get; } = new() { "Visa", "Master Card", "American Express" }; + + public List PaymentStatuses { get; } = new() { "Accepted", "Rejected" }; [HttpPost] [Route("performpayment")] @@ -22,8 +23,8 @@ public IEnumerable PerformPayment(int userId, string reference) // the payment system returns the response in a list of string like this: payment status, card type, card number, user and reference return new[] { - _paymentStatuses[new Random().Next(0, 2)], - _cardTypes[new Random().Next(0, 3)], + PaymentStatuses[new Random().Next(0, 2)], + CardTypes[new Random().Next(0, 3)], Guid.NewGuid().ToString(), userId.ToString(), reference diff --git a/ExternalSystem/PaymentService/PaymentService.csproj b/ExternalSystem/PaymentService/PaymentService.csproj index 094cb5a..0a5881b 100644 --- a/ExternalSystem/PaymentService/PaymentService.csproj +++ b/ExternalSystem/PaymentService/PaymentService.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 ..\..\docker-compose.dcproj diff --git a/ExternalSystem/PaymentService/Properties/PublishProfiles/PaymentServiceExternal - Web Deploy.pubxml b/ExternalSystem/PaymentService/Properties/PublishProfiles/PaymentServiceExternal - Web Deploy.pubxml index 0b0fe35..1c3d4b7 100644 --- a/ExternalSystem/PaymentService/Properties/PublishProfiles/PaymentServiceExternal - Web Deploy.pubxml +++ b/ExternalSystem/PaymentService/Properties/PublishProfiles/PaymentServiceExternal - Web Deploy.pubxml @@ -14,7 +14,11 @@ by editing this MSBuild file. In order to learn more about this please visit htt https://paymentserviceexternal.azurewebsites.net True False +<<<<<<< HEAD netcoreapp3.1 +======= + net6.0 +>>>>>>> template/master 8504d9b8-c4e8-4172-8da3-cbd9971e3207 false paymentserviceexternal.scm.azurewebsites.net:443 diff --git a/ExternalSystem/PaymentService/appsettings.json b/ExternalSystem/PaymentService/appsettings.json index 26bb0ac..925be0b 100644 --- a/ExternalSystem/PaymentService/appsettings.json +++ b/ExternalSystem/PaymentService/appsettings.json @@ -6,10 +6,6 @@ "Default": "Warning" } }, - "Console": { - "LogLevel": { - "Default": "Warning" - } - } + "IncludeScopes": false } } diff --git a/ServiceFabric/Linux/DuberMicroservices/DuberMicroservices.sfproj b/ServiceFabric/Linux/DuberMicroservices/DuberMicroservices.sfproj index 55ecc9d..d6db967 100644 --- a/ServiceFabric/Linux/DuberMicroservices/DuberMicroservices.sfproj +++ b/ServiceFabric/Linux/DuberMicroservices/DuberMicroservices.sfproj @@ -1,11 +1,11 @@  - + d8a868b6-7d03-4368-a52e-64f1e1b357db 2.1 1.5 - 1.6.6 + 1.7.6 v4.6.1 @@ -40,9 +40,9 @@ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\Service Fabric Tools\Microsoft.VisualStudio.Azure.Fabric.ApplicationProject.targets - - - - + + + + \ No newline at end of file diff --git a/ServiceFabric/Linux/DuberMicroservices/packages.config b/ServiceFabric/Linux/DuberMicroservices/packages.config index 2b70012..01e1c2b 100644 --- a/ServiceFabric/Linux/DuberMicroservices/packages.config +++ b/ServiceFabric/Linux/DuberMicroservices/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..e69de29 diff --git a/src/Application/Duber.Invoice.API/Application/DomainEventHandlers/InvoiceCreatedDomainEventHandler.cs b/src/Application/Duber.Invoice.API/Application/DomainEventHandlers/InvoiceCreatedDomainEventHandler.cs index a3f3aa3..9392272 100644 --- a/src/Application/Duber.Invoice.API/Application/DomainEventHandlers/InvoiceCreatedDomainEventHandler.cs +++ b/src/Application/Duber.Invoice.API/Application/DomainEventHandlers/InvoiceCreatedDomainEventHandler.cs @@ -5,10 +5,11 @@ using Duber.Infrastructure.EventBus.Abstractions; using Duber.Invoice.API.Application.IntegrationEvents.Events; using MediatR; +using System.Threading; namespace Duber.Invoice.API.Application.DomainEventHandlers { - public class InvoiceCreatedDomainEventHandler : IAsyncNotificationHandler + public class InvoiceCreatedDomainEventHandler : INotificationHandler { private readonly IEventBus _eventBus; private readonly IMapper _mapper; @@ -19,7 +20,7 @@ public InvoiceCreatedDomainEventHandler(IEventBus eventBus, IMapper mapper) _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); } - public async Task Handle(InvoiceCreatedDomainEvent notification) + public async Task Handle(InvoiceCreatedDomainEvent notification, CancellationToken cancellationToken) { // to update the query side (materialized view) var integrationEvent = _mapper.Map(notification); diff --git a/src/Application/Duber.Invoice.API/Application/DomainEventHandlers/InvoicePaidDomainEventHandler.cs b/src/Application/Duber.Invoice.API/Application/DomainEventHandlers/InvoicePaidDomainEventHandler.cs index d7f3699..1663f3a 100644 --- a/src/Application/Duber.Invoice.API/Application/DomainEventHandlers/InvoicePaidDomainEventHandler.cs +++ b/src/Application/Duber.Invoice.API/Application/DomainEventHandlers/InvoicePaidDomainEventHandler.cs @@ -5,10 +5,11 @@ using Duber.Infrastructure.EventBus.Abstractions; using Duber.Invoice.API.Application.IntegrationEvents.Events; using MediatR; +using System.Threading; namespace Duber.Invoice.API.Application.DomainEventHandlers { - public class InvoicePaidDomainEventHandler : IAsyncNotificationHandler + public class InvoicePaidDomainEventHandler : INotificationHandler { private readonly IEventBus _eventBus; private readonly IMapper _mapper; @@ -19,7 +20,7 @@ public InvoicePaidDomainEventHandler(IEventBus eventBus, IMapper mapper) _mapper = mapper ?? throw new ArgumentNullException(nameof(mapper)); } - public async Task Handle(InvoicePaidDomainEvent notification) + public async Task Handle(InvoicePaidDomainEvent notification, CancellationToken cancellationToken) { // to update the query side (materialized view) var integrationEvent = _mapper.Map(notification); diff --git a/src/Application/Duber.Invoice.API/Duber.Invoice.API.csproj b/src/Application/Duber.Invoice.API/Duber.Invoice.API.csproj index 2811158..aa6dc25 100644 --- a/src/Application/Duber.Invoice.API/Duber.Invoice.API.csproj +++ b/src/Application/Duber.Invoice.API/Duber.Invoice.API.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 ..\..\..\docker-compose.dcproj @@ -20,16 +20,17 @@ - - - - - - - - - - + + + + + + + + + + + diff --git a/src/Application/Duber.Invoice.API/Infrastructure/AutofacModules/MediatorModule.cs b/src/Application/Duber.Invoice.API/Infrastructure/AutofacModules/MediatorModule.cs index 1a9b247..18bda35 100644 --- a/src/Application/Duber.Invoice.API/Infrastructure/AutofacModules/MediatorModule.cs +++ b/src/Application/Duber.Invoice.API/Infrastructure/AutofacModules/MediatorModule.cs @@ -1,8 +1,8 @@ -using System.Collections.Generic; -using System.Reflection; -using Autofac; +using Autofac; using Duber.Invoice.API.Application.DomainEventHandlers; using MediatR; +using System.Collections.Generic; +using System.Reflection; namespace Duber.Invoice.API.Infrastructure.AutofacModules { @@ -10,26 +10,29 @@ public class MediatorModule : Autofac.Module { protected override void Load(ContainerBuilder builder) { - builder.RegisterAssemblyTypes(typeof(IMediator).GetTypeInfo().Assembly) - .AsImplementedInterfaces(); - // Register all the event classes (they implement IAsyncNotificationHandler) in assembly holding the Commands + Autofac.Builder.IRegistrationBuilder registrationBuilder2 = builder.RegisterType().As(); + + // Register all the event classes (they implement INotificationHandler) in assembly holding the Commands builder.RegisterAssemblyTypes(typeof(InvoiceCreatedDomainEventHandler).GetTypeInfo().Assembly) - .AsClosedTypesOf(typeof(IAsyncNotificationHandler<>)); + .AsClosedTypesOf(typeof(INotificationHandler<>)).AsImplementedInterfaces().InstancePerRequest(); - builder.Register(context => + Autofac.Builder.IRegistrationBuilder registrationBuilder1 = builder.Register(context => { - var componentContext = context.Resolve(); - return t => { object o; return componentContext.TryResolve(t, out o) ? o : null; }; + IComponentContext componentContext = context.Resolve(); + return t => + { + ServiceFactory p = t => { return componentContext.TryResolve(t, out object o) ? o : null; }; + return t; + }; }); - builder.Register(context => + Autofac.Builder.IRegistrationBuilder registrationBuilder = builder.Register(context => { - var componentContext = context.Resolve(); - + IComponentContext componentContext = context.Resolve(); return t => { - var resolved = (IEnumerable)componentContext.Resolve(typeof(IEnumerable<>).MakeGenericType(t)); + IEnumerable resolved = (IEnumerable)componentContext.Resolve(typeof(IEnumerable<>).MakeGenericType(t)); return resolved; }; }); diff --git a/src/Application/Duber.Invoice.API/Startup.cs b/src/Application/Duber.Invoice.API/Startup.cs index af0fd94..725b7e2 100644 --- a/src/Application/Duber.Invoice.API/Startup.cs +++ b/src/Application/Duber.Invoice.API/Startup.cs @@ -36,7 +36,7 @@ public Startup(IConfiguration configuration) public IServiceProvider ConfigureServices(IServiceCollection services) { services - .AddAutoMapper() + .AddAutoMapper(typeof(Startup)) .AddApplicationInsightsTelemetry(Configuration) .AddControllers(options => { @@ -72,7 +72,7 @@ public IServiceProvider ConfigureServices(IServiceCollection services) } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. - public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { diff --git a/src/Application/Duber.Trip.API/Application/DomainEventHandlers/TripCreatedDomainEventHandlerAsync.cs b/src/Application/Duber.Trip.API/Application/DomainEventHandlers/TripCreatedDomainEventHandlerAsync.cs index 6f5ec9f..5de248c 100644 --- a/src/Application/Duber.Trip.API/Application/DomainEventHandlers/TripCreatedDomainEventHandlerAsync.cs +++ b/src/Application/Duber.Trip.API/Application/DomainEventHandlers/TripCreatedDomainEventHandlerAsync.cs @@ -4,7 +4,7 @@ using Duber.Domain.Trip.Events; using Duber.Infrastructure.EventBus.Abstractions; using Duber.Trip.API.Application.IntegrationEvents; -using Kledex.Events; +using OpenCqrs.Events; using Microsoft.Extensions.Logging; namespace Duber.Trip.API.Application.DomainEventHandlers diff --git a/src/Application/Duber.Trip.API/Application/DomainEventHandlers/TripUpdatedDomainEventHandlerAsync.cs b/src/Application/Duber.Trip.API/Application/DomainEventHandlers/TripUpdatedDomainEventHandlerAsync.cs index d78792e..f268fad 100644 --- a/src/Application/Duber.Trip.API/Application/DomainEventHandlers/TripUpdatedDomainEventHandlerAsync.cs +++ b/src/Application/Duber.Trip.API/Application/DomainEventHandlers/TripUpdatedDomainEventHandlerAsync.cs @@ -6,7 +6,7 @@ using Duber.Infrastructure.EventBus.Idempotency; using Duber.Trip.API.Application.IntegrationEvents; using Duber.Trip.API.Application.Model; -using Kledex.Events; +using OpenCqrs.Events; using Microsoft.Extensions.Logging; using TripStatus = Duber.Domain.SharedKernel.Model.TripStatus; diff --git a/src/Application/Duber.Trip.API/Controllers/EventStoreController.cs b/src/Application/Duber.Trip.API/Controllers/EventStoreController.cs index 8e1b1d0..3d40822 100644 --- a/src/Application/Duber.Trip.API/Controllers/EventStoreController.cs +++ b/src/Application/Duber.Trip.API/Controllers/EventStoreController.cs @@ -3,7 +3,7 @@ using System.Net; using System.Threading.Tasks; using Duber.Trip.API.Infrastructure.Repository; -using Kledex.Store.Cosmos.Mongo.Documents; +using OpenCqrs.Store.Cosmos.Mongo.Documents; using Microsoft.AspNetCore.Mvc; namespace Duber.Trip.API.Controllers diff --git a/src/Application/Duber.Trip.API/Controllers/TripController.cs b/src/Application/Duber.Trip.API/Controllers/TripController.cs index 9709a97..a1c09db 100644 --- a/src/Application/Duber.Trip.API/Controllers/TripController.cs +++ b/src/Application/Duber.Trip.API/Controllers/TripController.cs @@ -3,8 +3,8 @@ using System.Threading.Tasks; using AutoMapper; using Duber.Domain.Trip.Commands; -using Kledex; -using Kledex.Domain; +using OpenCqrs; +using OpenCqrs.Domain; using Microsoft.ApplicationInsights.AspNetCore.Extensions; using Microsoft.AspNetCore.Mvc; using Action = Duber.Domain.Trip.Commands.Action; diff --git a/src/Application/Duber.Trip.API/Duber.Trip.API.csproj b/src/Application/Duber.Trip.API/Duber.Trip.API.csproj index 19a38ac..ee3c47b 100644 --- a/src/Application/Duber.Trip.API/Duber.Trip.API.csproj +++ b/src/Application/Duber.Trip.API/Duber.Trip.API.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 ..\..\..\docker-compose.dcproj @@ -18,15 +18,17 @@ - - - - - - - - - + + + + + + + + + + + diff --git a/src/Application/Duber.Trip.API/Extensions/ServiceCollectionExtensions.cs b/src/Application/Duber.Trip.API/Extensions/ServiceCollectionExtensions.cs index d024042..0e0ce59 100644 --- a/src/Application/Duber.Trip.API/Extensions/ServiceCollectionExtensions.cs +++ b/src/Application/Duber.Trip.API/Extensions/ServiceCollectionExtensions.cs @@ -12,16 +12,16 @@ using Duber.Infrastructure.EventBus.Idempotency; using Duber.Infrastructure.EventBus.RabbitMQ.IoC; using Duber.Infrastructure.EventBus.ServiceBus.IoC; -using Kledex; -using Kledex.Commands; -using Kledex.Configuration; -using Kledex.Domain; -using Kledex.Events; -using Kledex.Extensions; -using Kledex.Queries; -using Kledex.Store.Cosmos.Mongo.Configuration; +using OpenCqrs; +using OpenCqrs.Commands; +using OpenCqrs.Configuration; +using OpenCqrs.Domain; +using OpenCqrs.Events; +using OpenCqrs.Extensions; +using OpenCqrs.Queries; +using OpenCqrs.Store.Cosmos.Mongo.Configuration; using Microsoft.OpenApi.Models; -using Kledex.Store.Cosmos.Mongo.Extensions; +using OpenCqrs.Store.Cosmos.Mongo.Extensions; using MongoDB.Bson.Serialization; using Microsoft.Extensions.Diagnostics.HealthChecks; @@ -72,7 +72,7 @@ public static IServiceCollection AddCustomSwagger(this IServiceCollection servic /// /// /// - public static IKledexServiceBuilder AddCustomKledex(this IServiceCollection services, Action setupAction, params Type[] types) + public static IOpenCqrsServiceBuilder AddCustomKledex(this IServiceCollection services, Action setupAction, params Type[] types) { var typeList = types.ToList(); typeList.Add(typeof(IDispatcher)); @@ -85,7 +85,7 @@ public static IKledexServiceBuilder AddCustomKledex(this IServiceCollection serv services.AddTransient(typeof(IRepository<>), typeof(Repository<>)); services.AddCustomAutoMapper(typeList); services.Configure(setupAction); - return new KledexServiceBuilder(services); + return new OpenCqrsServiceBuilder(services); } private static IServiceCollection AddCustomAutoMapper(this IServiceCollection services, List types) diff --git a/src/Application/Duber.Trip.API/Infrastructure/Repository/EventStoreRepository.cs b/src/Application/Duber.Trip.API/Infrastructure/Repository/EventStoreRepository.cs index 8cd2233..db955df 100644 --- a/src/Application/Duber.Trip.API/Infrastructure/Repository/EventStoreRepository.cs +++ b/src/Application/Duber.Trip.API/Infrastructure/Repository/EventStoreRepository.cs @@ -1,9 +1,9 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Kledex.Store.Cosmos.Mongo; -using Kledex.Store.Cosmos.Mongo.Configuration; -using Kledex.Store.Cosmos.Mongo.Documents; +using OpenCqrs.Store.Cosmos.Mongo; +using OpenCqrs.Store.Cosmos.Mongo.Configuration; +using OpenCqrs.Store.Cosmos.Mongo.Documents; using Microsoft.Extensions.Options; using MongoDB.Driver; // ReSharper disable FunctionRecursiveOnAllPaths diff --git a/src/Application/Duber.Trip.API/Infrastructure/Repository/IEventStoreRepository.cs b/src/Application/Duber.Trip.API/Infrastructure/Repository/IEventStoreRepository.cs index ae6c1a6..987f175 100644 --- a/src/Application/Duber.Trip.API/Infrastructure/Repository/IEventStoreRepository.cs +++ b/src/Application/Duber.Trip.API/Infrastructure/Repository/IEventStoreRepository.cs @@ -1,7 +1,7 @@ using System; using System.Collections.Generic; using System.Threading.Tasks; -using Kledex.Store.Cosmos.Mongo.Documents; +using OpenCqrs.Store.Cosmos.Mongo.Documents; namespace Duber.Trip.API.Infrastructure.Repository { diff --git a/src/Application/Duber.Trip.API/Infrastructure/Repository/IdempotencyStoreProvider.cs b/src/Application/Duber.Trip.API/Infrastructure/Repository/IdempotencyStoreProvider.cs index 92b6db1..7c8275c 100644 --- a/src/Application/Duber.Trip.API/Infrastructure/Repository/IdempotencyStoreProvider.cs +++ b/src/Application/Duber.Trip.API/Infrastructure/Repository/IdempotencyStoreProvider.cs @@ -1,6 +1,6 @@ using System.Threading.Tasks; using Duber.Infrastructure.EventBus.Idempotency; -using Kledex.Store.Cosmos.Mongo.Configuration; +using OpenCqrs.Store.Cosmos.Mongo.Configuration; using Microsoft.Extensions.Options; using MongoDB.Driver; diff --git a/src/Application/Duber.Trip.Notifications/Duber.Trip.Notifications.csproj b/src/Application/Duber.Trip.Notifications/Duber.Trip.Notifications.csproj index 8869f8b..0bdce0c 100644 --- a/src/Application/Duber.Trip.Notifications/Duber.Trip.Notifications.csproj +++ b/src/Application/Duber.Trip.Notifications/Duber.Trip.Notifications.csproj @@ -1,18 +1,18 @@  - netcoreapp3.1 + net6.0 Linux ..\..\.. - + - + - - + + diff --git a/src/Domain/Driver/Duber.Domain.Driver.UnitTest/Duber.Domain.Driver.UnitTest.csproj b/src/Domain/Driver/Duber.Domain.Driver.UnitTest/Duber.Domain.Driver.UnitTest.csproj index e1d6178..23dcce1 100644 --- a/src/Domain/Driver/Duber.Domain.Driver.UnitTest/Duber.Domain.Driver.UnitTest.csproj +++ b/src/Domain/Driver/Duber.Domain.Driver.UnitTest/Duber.Domain.Driver.UnitTest.csproj @@ -1,15 +1,15 @@  - netcoreapp3.1 + net6.0 false - - - + + + diff --git a/src/Domain/Driver/Duber.Domain.Driver/Duber.Domain.Driver.csproj b/src/Domain/Driver/Duber.Domain.Driver/Duber.Domain.Driver.csproj index 4c339e2..6b8b5d4 100644 --- a/src/Domain/Driver/Duber.Domain.Driver/Duber.Domain.Driver.csproj +++ b/src/Domain/Driver/Duber.Domain.Driver/Duber.Domain.Driver.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 @@ -18,10 +18,13 @@ - - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/Domain/Duber.Domain.ACL/Duber.Domain.ACL.csproj b/src/Domain/Duber.Domain.ACL/Duber.Domain.ACL.csproj index 86e4070..f64bf9c 100644 --- a/src/Domain/Duber.Domain.ACL/Duber.Domain.ACL.csproj +++ b/src/Domain/Duber.Domain.ACL/Duber.Domain.ACL.csproj @@ -1,11 +1,11 @@  - netcoreapp3.1 + net6.0 - + diff --git a/src/Domain/Duber.Domain.SharedKernel/Duber.Domain.SharedKernel.csproj b/src/Domain/Duber.Domain.SharedKernel/Duber.Domain.SharedKernel.csproj index 95a2eaa..0c2b5a8 100644 --- a/src/Domain/Duber.Domain.SharedKernel/Duber.Domain.SharedKernel.csproj +++ b/src/Domain/Duber.Domain.SharedKernel/Duber.Domain.SharedKernel.csproj @@ -1,9 +1,13 @@  - netcoreapp3.1 + net6.0 + + + + diff --git a/src/Domain/Invoice/Duber.Domain.Invoice.UnitTest/Duber.Domain.Invoice.UnitTest.csproj b/src/Domain/Invoice/Duber.Domain.Invoice.UnitTest/Duber.Domain.Invoice.UnitTest.csproj index e1d6178..1da45f7 100644 --- a/src/Domain/Invoice/Duber.Domain.Invoice.UnitTest/Duber.Domain.Invoice.UnitTest.csproj +++ b/src/Domain/Invoice/Duber.Domain.Invoice.UnitTest/Duber.Domain.Invoice.UnitTest.csproj @@ -1,15 +1,16 @@  - netcoreapp3.1 + net6.0 false - - - + + + + diff --git a/src/Domain/Invoice/Duber.Domain.Invoice/Duber.Domain.Invoice.csproj b/src/Domain/Invoice/Duber.Domain.Invoice/Duber.Domain.Invoice.csproj index 1a7db45..9127871 100644 --- a/src/Domain/Invoice/Duber.Domain.Invoice/Duber.Domain.Invoice.csproj +++ b/src/Domain/Invoice/Duber.Domain.Invoice/Duber.Domain.Invoice.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 @@ -9,10 +9,15 @@ - - - - + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + @@ -23,7 +28,7 @@ - + diff --git a/src/Domain/Trip/Duber.Domain.Trip.UnitTest/Duber.Domain.Trip.UnitTest.csproj b/src/Domain/Trip/Duber.Domain.Trip.UnitTest/Duber.Domain.Trip.UnitTest.csproj index e1d6178..23dcce1 100644 --- a/src/Domain/Trip/Duber.Domain.Trip.UnitTest/Duber.Domain.Trip.UnitTest.csproj +++ b/src/Domain/Trip/Duber.Domain.Trip.UnitTest/Duber.Domain.Trip.UnitTest.csproj @@ -1,15 +1,15 @@  - netcoreapp3.1 + net6.0 false - - - + + + diff --git a/src/Domain/Trip/Duber.Domain.Trip/Commands/CreateTripCommand.cs b/src/Domain/Trip/Duber.Domain.Trip/Commands/CreateTripCommand.cs index 1120adc..50dd919 100644 --- a/src/Domain/Trip/Duber.Domain.Trip/Commands/CreateTripCommand.cs +++ b/src/Domain/Trip/Duber.Domain.Trip/Commands/CreateTripCommand.cs @@ -1,6 +1,6 @@ using Duber.Domain.SharedKernel.Model; using Duber.Domain.Trip.Model; -using Kledex.Domain; +using OpenCqrs.Domain; namespace Duber.Domain.Trip.Commands { diff --git a/src/Domain/Trip/Duber.Domain.Trip/Commands/Handlers/CreateTripCommandHandlerAsync.cs b/src/Domain/Trip/Duber.Domain.Trip/Commands/Handlers/CreateTripCommandHandlerAsync.cs index ccd333e..ebdffd2 100644 --- a/src/Domain/Trip/Duber.Domain.Trip/Commands/Handlers/CreateTripCommandHandlerAsync.cs +++ b/src/Domain/Trip/Duber.Domain.Trip/Commands/Handlers/CreateTripCommandHandlerAsync.cs @@ -1,5 +1,5 @@ using System.Threading.Tasks; -using Kledex.Commands; +using OpenCqrs.Commands; namespace Duber.Domain.Trip.Commands.Handlers { diff --git a/src/Domain/Trip/Duber.Domain.Trip/Commands/Handlers/UpdateTripCommandHandlerAsync.cs b/src/Domain/Trip/Duber.Domain.Trip/Commands/Handlers/UpdateTripCommandHandlerAsync.cs index ec690f2..92378c2 100644 --- a/src/Domain/Trip/Duber.Domain.Trip/Commands/Handlers/UpdateTripCommandHandlerAsync.cs +++ b/src/Domain/Trip/Duber.Domain.Trip/Commands/Handlers/UpdateTripCommandHandlerAsync.cs @@ -1,8 +1,8 @@ using System; using System.Threading.Tasks; using Duber.Domain.Trip.Exceptions; -using Kledex.Commands; -using Kledex.Domain; +using OpenCqrs.Commands; +using OpenCqrs.Domain; namespace Duber.Domain.Trip.Commands.Handlers { diff --git a/src/Domain/Trip/Duber.Domain.Trip/Commands/UpdateTripCommand.cs b/src/Domain/Trip/Duber.Domain.Trip/Commands/UpdateTripCommand.cs index c0d8040..6492705 100644 --- a/src/Domain/Trip/Duber.Domain.Trip/Commands/UpdateTripCommand.cs +++ b/src/Domain/Trip/Duber.Domain.Trip/Commands/UpdateTripCommand.cs @@ -1,5 +1,5 @@ using Duber.Domain.Trip.Model; -using Kledex.Domain; +using OpenCqrs.Domain; namespace Duber.Domain.Trip.Commands { diff --git a/src/Domain/Trip/Duber.Domain.Trip/Duber.Domain.Trip.csproj b/src/Domain/Trip/Duber.Domain.Trip/Duber.Domain.Trip.csproj index 8f0dee4..9d2c3b9 100644 --- a/src/Domain/Trip/Duber.Domain.Trip/Duber.Domain.Trip.csproj +++ b/src/Domain/Trip/Duber.Domain.Trip/Duber.Domain.Trip.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 @@ -15,7 +15,7 @@ - + diff --git a/src/Domain/Trip/Duber.Domain.Trip/Events/TripCreatedDomainEvent.cs b/src/Domain/Trip/Duber.Domain.Trip/Events/TripCreatedDomainEvent.cs index 908ddbf..4238ccf 100644 --- a/src/Domain/Trip/Duber.Domain.Trip/Events/TripCreatedDomainEvent.cs +++ b/src/Domain/Trip/Duber.Domain.Trip/Events/TripCreatedDomainEvent.cs @@ -1,6 +1,6 @@ using Duber.Domain.SharedKernel.Model; using Duber.Domain.Trip.Model; -using Kledex.Domain; +using OpenCqrs.Domain; namespace Duber.Domain.Trip.Events { diff --git a/src/Domain/Trip/Duber.Domain.Trip/Events/TripUpdatedDomainEvent.cs b/src/Domain/Trip/Duber.Domain.Trip/Events/TripUpdatedDomainEvent.cs index 4eaa11b..e2f4f21 100644 --- a/src/Domain/Trip/Duber.Domain.Trip/Events/TripUpdatedDomainEvent.cs +++ b/src/Domain/Trip/Duber.Domain.Trip/Events/TripUpdatedDomainEvent.cs @@ -1,7 +1,7 @@ using System; using Duber.Domain.SharedKernel.Model; using Duber.Domain.Trip.Model; -using Kledex.Domain; +using OpenCqrs.Domain; namespace Duber.Domain.Trip.Events { diff --git a/src/Domain/Trip/Duber.Domain.Trip/Model/Trip.cs b/src/Domain/Trip/Duber.Domain.Trip/Model/Trip.cs index 69a4750..2f79a93 100644 --- a/src/Domain/Trip/Duber.Domain.Trip/Model/Trip.cs +++ b/src/Domain/Trip/Duber.Domain.Trip/Model/Trip.cs @@ -3,7 +3,7 @@ using Duber.Domain.Trip.Events; using Duber.Domain.Trip.Exceptions; using GeoCoordinatePortable; -using Kledex.Domain; +using OpenCqrs.Domain; using Action = Duber.Domain.Trip.Events.Action; // ReSharper disable ConvertToAutoProperty // ReSharper disable UnusedAutoPropertyAccessor.Local diff --git a/src/Domain/User/Duber.Domain.User.UnitTest/Duber.Domain.User.UnitTest.csproj b/src/Domain/User/Duber.Domain.User.UnitTest/Duber.Domain.User.UnitTest.csproj index e1d6178..23dcce1 100644 --- a/src/Domain/User/Duber.Domain.User.UnitTest/Duber.Domain.User.UnitTest.csproj +++ b/src/Domain/User/Duber.Domain.User.UnitTest/Duber.Domain.User.UnitTest.csproj @@ -1,15 +1,15 @@  - netcoreapp3.1 + net6.0 false - - - + + + diff --git a/src/Domain/User/Duber.Domain.User/Duber.Domain.User.csproj b/src/Domain/User/Duber.Domain.User/Duber.Domain.User.csproj index 86dc407..96e1d44 100644 --- a/src/Domain/User/Duber.Domain.User/Duber.Domain.User.csproj +++ b/src/Domain/User/Duber.Domain.User/Duber.Domain.User.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 @@ -9,10 +9,13 @@ - - - - + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + diff --git a/src/Infrastructure/Duber.Infrastructure.Resilience.Abstractions/Duber.Infrastructure.Resilience.Abstractions.csproj b/src/Infrastructure/Duber.Infrastructure.Resilience.Abstractions/Duber.Infrastructure.Resilience.Abstractions.csproj index 418b4b6..c3eb489 100644 --- a/src/Infrastructure/Duber.Infrastructure.Resilience.Abstractions/Duber.Infrastructure.Resilience.Abstractions.csproj +++ b/src/Infrastructure/Duber.Infrastructure.Resilience.Abstractions/Duber.Infrastructure.Resilience.Abstractions.csproj @@ -1,11 +1,11 @@  - netcoreapp3.1 + net6.0 - + diff --git a/src/Infrastructure/Duber.Infrastructure.Resilience.Http/Duber.Infrastructure.Resilience.Http.csproj b/src/Infrastructure/Duber.Infrastructure.Resilience.Http/Duber.Infrastructure.Resilience.Http.csproj index 9ffb2b0..36e5c32 100644 --- a/src/Infrastructure/Duber.Infrastructure.Resilience.Http/Duber.Infrastructure.Resilience.Http.csproj +++ b/src/Infrastructure/Duber.Infrastructure.Resilience.Http/Duber.Infrastructure.Resilience.Http.csproj @@ -1,12 +1,12 @@  - netcoreapp3.1 + net6.0 - + diff --git a/src/Infrastructure/Duber.Infrastructure.Resilience.Sql/Duber.Infrastructure.Resilience.Sql.csproj b/src/Infrastructure/Duber.Infrastructure.Resilience.Sql/Duber.Infrastructure.Resilience.Sql.csproj index a7d22ce..c7e00dc 100644 --- a/src/Infrastructure/Duber.Infrastructure.Resilience.Sql/Duber.Infrastructure.Resilience.Sql.csproj +++ b/src/Infrastructure/Duber.Infrastructure.Resilience.Sql/Duber.Infrastructure.Resilience.Sql.csproj @@ -1,12 +1,12 @@  - netcoreapp3.1 + net6.0 - - + + diff --git a/src/Infrastructure/Duber.Infrastructure.WebHost/Duber.Infrastructure.WebHost.csproj b/src/Infrastructure/Duber.Infrastructure.WebHost/Duber.Infrastructure.WebHost.csproj index 47076f3..3f13e25 100644 --- a/src/Infrastructure/Duber.Infrastructure.WebHost/Duber.Infrastructure.WebHost.csproj +++ b/src/Infrastructure/Duber.Infrastructure.WebHost/Duber.Infrastructure.WebHost.csproj @@ -1,12 +1,12 @@  - netcoreapp3.1 + net6.0 - + diff --git a/src/Infrastructure/Duber.Infrastructure/Duber.Infrastructure.csproj b/src/Infrastructure/Duber.Infrastructure/Duber.Infrastructure.csproj index bc16783..fb0e9b7 100644 --- a/src/Infrastructure/Duber.Infrastructure/Duber.Infrastructure.csproj +++ b/src/Infrastructure/Duber.Infrastructure/Duber.Infrastructure.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 @@ -10,10 +10,10 @@ - + - - + + diff --git a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.Idempotency/Duber.Infrastructure.EventBus.Idempotency.csproj b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.Idempotency/Duber.Infrastructure.EventBus.Idempotency.csproj index 6942467..32aa322 100644 --- a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.Idempotency/Duber.Infrastructure.EventBus.Idempotency.csproj +++ b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.Idempotency/Duber.Infrastructure.EventBus.Idempotency.csproj @@ -1,11 +1,11 @@ - + - netcoreapp3.1 + net6.0 - + diff --git a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.RabbitMQ/Duber.Infrastructure.EventBus.RabbitMQ.csproj b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.RabbitMQ/Duber.Infrastructure.EventBus.RabbitMQ.csproj index 7d3494e..cdfc779 100644 --- a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.RabbitMQ/Duber.Infrastructure.EventBus.RabbitMQ.csproj +++ b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.RabbitMQ/Duber.Infrastructure.EventBus.RabbitMQ.csproj @@ -1,17 +1,17 @@  - netcoreapp3.1 + net6.0 - - - - - - - + + + + + + + diff --git a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.RabbitMQ/EventBusRabbitMQ.cs b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.RabbitMQ/EventBusRabbitMQ.cs index 4c6be2c..5639192 100644 --- a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.RabbitMQ/EventBusRabbitMQ.cs +++ b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.RabbitMQ/EventBusRabbitMQ.cs @@ -48,17 +48,16 @@ private void SubsManager_OnEventRemoved(object sender, string eventName) _persistentConnection.TryConnect(); } - using (var channel = _persistentConnection.CreateModel()) - { - channel.QueueUnbind(queue: _queueName, - exchange: BROKER_NAME, - routingKey: eventName); + IModel model = _persistentConnection.CreateModel(); + using IModel channel = model; + channel.QueueUnbind(queue: _queueName, + exchange: BROKER_NAME, + routingKey: eventName); - if (_subsManager.IsEmpty) - { - _queueName = string.Empty; - _consumerChannel.Close(); - } + if (_subsManager.IsEmpty) + { + _queueName = string.Empty; + _consumerChannel.Close(); } } @@ -73,32 +72,30 @@ public void Publish(IntegrationEvent @event) .Or() .WaitAndRetry(_retryCount, retryAttempt => TimeSpan.FromSeconds(Math.Pow(2, retryAttempt)), (ex, time) => { - _logger.LogWarning(ex.ToString()); + _logger.LogWarning(message: ex.ToString()); }); - using (var channel = _persistentConnection.CreateModel()) - { - var eventName = @event.GetType().Name; - channel.ExchangeDeclare(exchange: BROKER_NAME, type: "direct"); + using var channel = _persistentConnection.CreateModel(); + var eventName = @event.GetType().Name; + channel.ExchangeDeclare(exchange: BROKER_NAME, type: "direct"); - var message = JsonConvert.SerializeObject(@event); - var body = Encoding.UTF8.GetBytes(message); + var message = JsonConvert.SerializeObject(@event); + var body = Encoding.UTF8.GetBytes(message); - // to avoid lossing messages - var properties = channel.CreateBasicProperties(); - properties.DeliveryMode = 2; // persistent - properties.Expiration = "60000"; + // to avoid lossing messages + var properties = channel.CreateBasicProperties(); + properties.DeliveryMode = 2; // persistent + properties.Expiration = "60000"; - policy.Execute(() => - { - channel.BasicPublish( - exchange: BROKER_NAME, - routingKey: eventName, - mandatory: true, - basicProperties: properties, - body: body); - }); - } + policy.Execute(() => + { + channel.BasicPublish( + exchange: BROKER_NAME, + routingKey: eventName, + mandatory: true, + basicProperties: properties, + body: body); + }); } public void SubscribeDynamic(string eventName) @@ -129,12 +126,10 @@ private void DoInternalSubscription(string eventName) _persistentConnection.TryConnect(); } - using (var channel = _persistentConnection.CreateModel()) - { - channel.QueueBind(queue: _queueName, - exchange: BROKER_NAME, - routingKey: eventName); - } + using var channel = _persistentConnection.CreateModel(); + channel.QueueBind(queue: _queueName, + exchange: BROKER_NAME, + routingKey: eventName); } } @@ -181,14 +176,23 @@ private void StartBasicConsume() private async Task Consumer_Received(object sender, BasicDeliverEventArgs eventArgs) { var eventName = eventArgs.RoutingKey; - var message = Encoding.UTF8.GetString(eventArgs.Body); + string message = Encoding.UTF8.GetString(eventArgs.Body.ToArray()); try { + void onRetry(Exception ex, TimeSpan time) + { + if (ex is null) + { + throw new ArgumentNullException(nameof(ex)); + } + + _logger.LogWarning(message: ex.ToString()); + } var policy = Policy.Handle() .Or() .WaitAndRetryAsync(_retryCount, retryAttempt => TimeSpan.FromSeconds(1), - (ex, time) => { _logger.LogWarning(ex.ToString()); }); + onRetry); await policy.ExecuteAsync(async () => await ProcessEvent(eventName, message)); @@ -240,31 +244,28 @@ private async Task ProcessEvent(string eventName, string message) if (_subsManager.HasSubscriptionsForEvent(eventName)) { - using (var scope = _autofac.BeginLifetimeScope(AUTOFAC_SCOPE_NAME)) + using var scope = _autofac.BeginLifetimeScope(AUTOFAC_SCOPE_NAME); + var subscriptions = _subsManager.GetHandlersForEvent(eventName); + foreach (var subscription in subscriptions) { - var subscriptions = _subsManager.GetHandlersForEvent(eventName); - foreach (var subscription in subscriptions) + if (subscription.IsDynamic) + { + if (scope.ResolveOptional(subscription.HandlerType) is not IDynamicIntegrationEventHandler handler) continue; + dynamic eventData = JObject.Parse(message); + + await Task.Yield(); + await handler.Handle(eventData); + } + else { - if (subscription.IsDynamic) - { - var handler = scope.ResolveOptional(subscription.HandlerType) as IDynamicIntegrationEventHandler; - if (handler == null) continue; - dynamic eventData = JObject.Parse(message); - - await Task.Yield(); - await handler.Handle(eventData); - } - else - { - var handler = scope.ResolveOptional(subscription.HandlerType); - if (handler == null) continue; - var eventType = _subsManager.GetEventTypeByName(eventName); - var integrationEvent = JsonConvert.DeserializeObject(message, eventType); - var concreteType = typeof(IIntegrationEventHandler<>).MakeGenericType(eventType); - - await Task.Yield(); - await (Task)concreteType.GetMethod("Handle").Invoke(handler, new object[] { integrationEvent }); - } + var handler = scope.ResolveOptional(subscription.HandlerType); + if (handler == null) continue; + var eventType = _subsManager.GetEventTypeByName(eventName); + var integrationEvent = JsonConvert.DeserializeObject(message, eventType); + var concreteType = typeof(IIntegrationEventHandler<>).MakeGenericType(eventType); + + await Task.Yield(); + await (Task)concreteType.GetMethod("Handle").Invoke(handler, new object[] { integrationEvent }); } } } diff --git a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.ServiceBus/Duber.Infrastructure.EventBus.ServiceBus.csproj b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.ServiceBus/Duber.Infrastructure.EventBus.ServiceBus.csproj index f47b0f8..5007ab8 100644 --- a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.ServiceBus/Duber.Infrastructure.EventBus.ServiceBus.csproj +++ b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.ServiceBus/Duber.Infrastructure.EventBus.ServiceBus.csproj @@ -1,18 +1,18 @@  - netcoreapp3.1 + net6.0 - - - - - - - - + + + + + + + + diff --git a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.ServiceBus/EventBusServiceBus.cs b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.ServiceBus/EventBusServiceBus.cs index 5feb638..a5d5ab3 100644 --- a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.ServiceBus/EventBusServiceBus.cs +++ b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus.ServiceBus/EventBusServiceBus.cs @@ -5,11 +5,11 @@ using Autofac; using Duber.Infrastructure.EventBus.Abstractions; using Duber.Infrastructure.EventBus.Events; -using Microsoft.Azure.ServiceBus; using Microsoft.Extensions.Logging; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Polly; +using Microsoft.Azure.ServiceBus; namespace Duber.Infrastructure.EventBus.ServiceBus { @@ -146,9 +146,7 @@ public void Dispose() _subsManager.Clear(); } - private void RegisterSubscriptionClientMessageHandler() - { - _subscriptionClient.RegisterMessageHandler( + private void RegisterSubscriptionClientMessageHandler() => _subscriptionClient.RegisterMessageHandler( async (message, token) => { var eventName = $"{message.Label}{INTEGRATION_EVENT_SUFFIX}"; @@ -164,8 +162,7 @@ private void RegisterSubscriptionClientMessageHandler() // Complete the message so that it is not received again. await _subscriptionClient.CompleteAsync(message.SystemProperties.LockToken); }, - new MessageHandlerOptions(ExceptionReceivedHandler) { MaxConcurrentCalls = 10, AutoComplete = false }); - } + messageHandlerOptions: new MessageHandlerOptions(ExceptionReceivedHandler) { MaxConcurrentCalls = 10, AutoComplete = false }); private static Task ExceptionReceivedHandler(ExceptionReceivedEventArgs exceptionReceivedEventArgs) { diff --git a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus/Abstractions/IEventBus.cs b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus/Abstractions/IEventBus.cs index f51b7e4..a8bb403 100644 --- a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus/Abstractions/IEventBus.cs +++ b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus/Abstractions/IEventBus.cs @@ -18,5 +18,6 @@ void Unsubscribe() where T : IntegrationEvent; void Publish(IntegrationEvent @event); + void Dispose(); } } diff --git a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus/Duber.Infrastructure.EventBus.csproj b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus/Duber.Infrastructure.EventBus.csproj index 7c4ae4c..fff7812 100644 --- a/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus/Duber.Infrastructure.EventBus.csproj +++ b/src/Infrastructure/EventBus/Duber.Infrastructure.EventBus/Duber.Infrastructure.EventBus.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 diff --git a/src/Web/Duber.WebSite/Duber.WebSite.csproj b/src/Web/Duber.WebSite/Duber.WebSite.csproj index a22caf0..e4e5d0f 100644 --- a/src/Web/Duber.WebSite/Duber.WebSite.csproj +++ b/src/Web/Duber.WebSite/Duber.WebSite.csproj @@ -1,7 +1,7 @@  - netcoreapp3.1 + net6.0 ..\..\..\docker-compose.dcproj @@ -13,17 +13,20 @@ - - - - - - + + + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + - - - - + + + +