diff --git a/src/Adapters/NetSampleArch.Adapters.Kafka/Handlers/PersonWasRegisteredHandler .cs b/src/Adapters/NetSampleArch.Adapters.Kafka/Handlers/PersonWasRegisteredHandler .cs index e95eb21..10f847f 100644 --- a/src/Adapters/NetSampleArch.Adapters.Kafka/Handlers/PersonWasRegisteredHandler .cs +++ b/src/Adapters/NetSampleArch.Adapters.Kafka/Handlers/PersonWasRegisteredHandler .cs @@ -1,6 +1,5 @@ using System.Threading; using System.Threading.Tasks; -using NetSampleArch.Adapters.Kafka.Handlers.Interfaces; using NetSampleArch.Infra.CrossCutting.Bus.Interfaces.Handlers; using NetSampleArch.Infra.CrossCutting.Configuration; using NetSampleArch.Infra.CrossCutting.Messages.Internal.Events.PersonWasRegistered.Interfaces; @@ -12,19 +11,16 @@ public class PersonWasRegisteredHandler : BaseKafkaHandler, IEventHandler { public PersonWasRegisteredHandler(ILogger logger, Configuration config) - : base(logger, config) - { - - } + : base(logger, config) { } public async override Task Handle(IPersonWasRegisteredEvent notification, CancellationToken cancellationToken) { - await KafkaPublisher.SendEventAsync( - topicName: "", - key: "", - @event: null, - cancellationToken - ).ConfigureAwait(false); + // await KafkaPublisher.SendEventAsync( + // topicName: "", + // key: "", + // @event: null, + // cancellationToken + // ).ConfigureAwait(false); } } } \ No newline at end of file diff --git a/src/Common/NetSampleArch.Infra.CrossCutting.IoC/InjectionManager.cs b/src/Common/NetSampleArch.Infra.CrossCutting.IoC/InjectionManager.cs index 573e078..a67e0e6 100644 --- a/src/Common/NetSampleArch.Infra.CrossCutting.IoC/InjectionManager.cs +++ b/src/Common/NetSampleArch.Infra.CrossCutting.IoC/InjectionManager.cs @@ -4,10 +4,12 @@ using MediatR; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using NetSampleArch.Adapters.Kafka.IoC; using NetSampleArch.Adapters.SQLServer.IoC; using NetSampleArch.Adapters.SQLServer.Repositories; using NetSampleArch.Adapters.SQLServer.Repositories.Interfaces; using NetSampleArch.Adapters.SQLServer.UnitOfWork.Interfaces; +using NetSampleArch.Application.IoC; using NetSampleArch.Infra.CrossCutting.Bus.Handlers.Events.DomainNotifications.Interfaces; using NetSampleArch.Infra.CrossCutting.UnitOfWork; @@ -26,20 +28,20 @@ public static void Inject(this IServiceCollection services, IConfiguration confi private static void ConfigureCommomLayer(IServiceCollection services, IConfiguration configuration) { - //CommomBootstrapper.ConfigureCrossCuttingLayer(services, configuration); + CommonInjectionManager.Inject(services, configuration); //CrossCutting.Messages.External.V1.IoC.CrossCuttingExternalMessagesBootstrapper.ConfigureCrossCuttingExternalMessages(services); } private static void ConfigureApplicationCoreLayer(IServiceCollection services) { - //ApplicationBootstrapper.ConfigureApplicationLayer(services); + ApplicationInjectionManager.Inject(services); //DomainBootstrapper.ConfigureDomainLayer(services); } private static void ConfigureAdaptersLayer(IServiceCollection services, IConfiguration config) { AdapterSqlServerInjectionManager.Inject(services); - AdapterKafkaBootstrapper.ConfigureAdapterKafkaLayer(services); + AdapterKafkaInjectionManager.Inject(services); services.AddScoped(serviceProvider => serviceProvider.GetService()); services.AddScoped(); @@ -51,9 +53,9 @@ private static void ConfigureMessageHandlerLayer(IServiceCollection services, IC // Commom typeof(IDomainNotificationEventHandler).Assembly, // Kafka Layer - typeof(IAssetKafkaRepository).Assembly, + //typeof(IAssetKafkaRepository).Assembly, - typeof(IPersonSqlServerRepository) + //typeof(IPersonSqlServerRepository) }; services.AddMediatR(config => diff --git a/src/Common/NetSampleArch.Infra.CrossCutting.IoC/NetSampleArch.Infra.CrossCutting.IoC.csproj b/src/Common/NetSampleArch.Infra.CrossCutting.IoC/NetSampleArch.Infra.CrossCutting.IoC.csproj index 0b853f0..8721578 100644 --- a/src/Common/NetSampleArch.Infra.CrossCutting.IoC/NetSampleArch.Infra.CrossCutting.IoC.csproj +++ b/src/Common/NetSampleArch.Infra.CrossCutting.IoC/NetSampleArch.Infra.CrossCutting.IoC.csproj @@ -3,7 +3,7 @@ net5.0 - + @@ -17,6 +17,10 @@ - + + + + + \ No newline at end of file diff --git a/src/Common/NetSampleArch.Infra.CrossCutting.Messages/Internal/Commands/ReplicatePersonCreated/Models/PersonCreatedEntry.cs b/src/Common/NetSampleArch.Infra.CrossCutting.Messages/Internal/Commands/ReplicatePersonCreated/Models/PersonCreatedEntry.cs index bf63c04..9dfc539 100644 --- a/src/Common/NetSampleArch.Infra.CrossCutting.Messages/Internal/Commands/ReplicatePersonCreated/Models/PersonCreatedEntry.cs +++ b/src/Common/NetSampleArch.Infra.CrossCutting.Messages/Internal/Commands/ReplicatePersonCreated/Models/PersonCreatedEntry.cs @@ -14,7 +14,7 @@ public class PersonCreatedEntry : BaseCommand public string Address { get; set; } public string Phone { get; set; } public PersonCreatedEntry(string executionUser, string createdBy, DateTime createdAt, - string updatedBy, DateTime updatedAt, TimeSpan rowVersion, string name, string address, string phone) + string updatedBy, DateTime? updatedAt, TimeSpan rowVersion, string name, string address, string phone) : base(executionUser) { CreatedBy = createdBy; diff --git a/src/Common/NetSampleArch.Infra.CrossCutting/IoC/CommonBootstraper.cs b/src/Common/NetSampleArch.Infra.CrossCutting/IoC/CommonInjectionManager.cs similarity index 97% rename from src/Common/NetSampleArch.Infra.CrossCutting/IoC/CommonBootstraper.cs rename to src/Common/NetSampleArch.Infra.CrossCutting/IoC/CommonInjectionManager.cs index ab86008..943c5a4 100644 --- a/src/Common/NetSampleArch.Infra.CrossCutting/IoC/CommonBootstraper.cs +++ b/src/Common/NetSampleArch.Infra.CrossCutting/IoC/CommonInjectionManager.cs @@ -11,7 +11,7 @@ namespace NetSampleArch.Infra.CrossCutting.IoC { - public static class CommonBootstraper + public static class CommonInjectionManager { private static string ELK_APPLICATION_PROPERTY_NAME = "NetArchSample"; diff --git a/src/Core/NetSampleArch.Application/IoC/ApplicationInjectionManager.cs b/src/Core/NetSampleArch.Application/IoC/ApplicationInjectionManager.cs new file mode 100644 index 0000000..2629dd0 --- /dev/null +++ b/src/Core/NetSampleArch.Application/IoC/ApplicationInjectionManager.cs @@ -0,0 +1,12 @@ +using Microsoft.Extensions.DependencyInjection; + +namespace NetSampleArch.Application.IoC +{ + public static class ApplicationInjectionManager + { + public static void Inject(IServiceCollection services) + { + + } + } +} \ No newline at end of file diff --git a/src/Core/NetSampleArch.Application/NetSampleArch.Application.csproj b/src/Core/NetSampleArch.Application/NetSampleArch.Application.csproj index feb4981..4c43d7e 100644 --- a/src/Core/NetSampleArch.Application/NetSampleArch.Application.csproj +++ b/src/Core/NetSampleArch.Application/NetSampleArch.Application.csproj @@ -5,7 +5,11 @@ + + + + - + \ No newline at end of file diff --git a/src/Ports/NetSampleArch.Ports.Consumers/Consumers/Commands/ReplicateCreatedPersonCommandConsumer.cs b/src/Ports/NetSampleArch.Ports.Consumers/Consumers/Commands/ReplicateCreatedPersonCommandConsumer.cs index d88f1d4..94f653c 100644 --- a/src/Ports/NetSampleArch.Ports.Consumers/Consumers/Commands/ReplicateCreatedPersonCommandConsumer.cs +++ b/src/Ports/NetSampleArch.Ports.Consumers/Consumers/Commands/ReplicateCreatedPersonCommandConsumer.cs @@ -4,6 +4,7 @@ using NetSampleArch.Infra.CrossCutting.Bus.Interfaces; using NetSampleArch.Infra.CrossCutting.Configuration; using NetSampleArch.Infra.CrossCutting.ExtensionMethods; +using NetSampleArch.Infra.CrossCutting.Messages.Internal.Commands.ReplicatePersonCreated; using NetSampleArch.Ports.Consumers.Interfaces.Commands; using Serilog; @@ -15,10 +16,27 @@ public class ReplicateCreatedPersonCommandConsumer public ReplicateCreatedPersonCommandConsumer(ILogger logger, IBus bus, Configuration configuration) : base(logger, bus, configuration) { } - public override Task MessageReceivedAsync(ConsumeResult receivedMessage, CancellationToken cancellationToken) + public override async Task MessageReceivedAsync(ConsumeResult receivedMessage, CancellationToken cancellationToken) { - var command = receivedMessage.Message.Value.DeserializeFromJson(); - return null; + var command = receivedMessage.Message.Value.DeserializeFromJson(); + + await Bus.SendCommandAsync( + new NetSampleArch.Infra.CrossCutting.Messages.Internal.Commands.ReplicatePersonCreated.ReplicatePersonCreatedCommand( + new Infra.CrossCutting.Messages.Internal.Commands.ReplicatePersonCreated.Models.PersonCreatedEntry + ( + executionUser: nameof(ReplicateCreatedPersonCommandConsumer), + createdAt: command.Entry.CreatedAt, + createdBy: command.Entry.CreatedBy, + updatedAt: command.Entry.UpdatedAt, + updatedBy: command.Entry.UpdatedBy, + rowVersion: command.Entry.RowVersion, + name: command.Entry.Name, + address: command.Entry.Address, + phone: command.Entry.Phone + ) + ), + cancellationToken + ).ConfigureAwait(false); } } } \ No newline at end of file