Skip to content

Commit 2775d84

Browse files
committed
Using Eventflow
0 parents  commit 2775d84

87 files changed

Lines changed: 2738 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.dockerignore
2+
.env
3+
.git
4+
.gitignore
5+
.vs
6+
.vscode
7+
docker-compose.yml
8+
docker-compose.*.yml
9+
*/bin
10+
*/obj

.gitignore

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
*.swp
2+
*.*~
3+
project.lock.json
4+
.DS_Store
5+
*.pyc
6+
nupkg/
7+
8+
# Visual Studio Code
9+
.vscode
10+
11+
# User-specific files
12+
*.suo
13+
*.user
14+
*.userosscache
15+
*.sln.docstates
16+
17+
# Build results
18+
[Dd]ebug/
19+
[Dd]ebugPublic/
20+
[Rr]elease/
21+
[Rr]eleases/
22+
x64/
23+
x86/
24+
build/
25+
bld/
26+
[Bb]in/
27+
[Oo]bj/
28+
[Oo]ut/
29+
msbuild.log
30+
msbuild.err
31+
msbuild.wrn
32+
33+
# Visual Studio 2015
34+
.vs/
35+
36+
[Aa]ppsettings.[Pp]roduction.json
37+
[Aa]ppsettings.[Ss]taging.json
38+
[Aa]ppsettings.[Dd]evelopment.json
39+
40+
API/API.xml
41+
logs/

Api.sln

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.29911.84
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Gateway", "Gateway", "{066150CB-B616-4E5B-A04A-C7ECDDC778FE}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructures", "Infrastructures", "{10DA4914-9BFF-42BA-8931-003C95F4D0DB}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "MicroServices", "MicroServices", "{7912080D-1F02-42E0-A440-AC2713C92603}"
11+
EndProject
12+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ServicesGateway", "Gateway\ServicesGateway\ServicesGateway.csproj", "{21A1F367-48AC-4820-80EC-F0C9B21006BE}"
13+
EndProject
14+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventStore.Middleware", "Infrastructures\EventStore.Middleware\EventStore.Middleware.csproj", "{51F06C26-E2E1-4918-88EE-6C81ABD3D86A}"
15+
EndProject
16+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Infrastructure", "Infrastructures\Infrastructure\Infrastructure.csproj", "{3C65B94C-6B47-4E84-A970-AEF8B3155556}"
17+
EndProject
18+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Domain", "Domain\Domain.csproj", "{DEE4082B-FE21-43F9-AF98-D0FF1EB03215}"
19+
EndProject
20+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Movies", "Movies", "{18272749-A72B-4A60-9961-F7225A594340}"
21+
EndProject
22+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Reviews", "Reviews", "{0E046BF8-EF83-4F06-9EE7-A72399D7BBFD}"
23+
EndProject
24+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Movies.ReadStore", "MicroServices\Movies\Movies.ReadStore\Movies.ReadStore.csproj", "{12CBC3CD-E73C-4A6E-BF6C-DFCEDAFF5DA7}"
25+
EndProject
26+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reviews.ReadStore", "MicroServices\Reviews\Reviews.ReadStore\Reviews.ReadStore.csproj", "{0D913F07-17CC-4BC8-A471-FA25A5AEAF83}"
27+
EndProject
28+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Movies.Service", "MicroServices\Movies\Movies.Service\Movies.Service.csproj", "{A2006E94-6521-43CC-8904-6BAA9AFAF3F9}"
29+
EndProject
30+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Reviews.Service", "MicroServices\Reviews\Reviews.Service\Reviews.Service.csproj", "{01339E7C-83FA-423F-B2AB-46D88BDCEE59}"
31+
EndProject
32+
Project("{E53339B2-1760-4266-BCC7-CA923CBCF16C}") = "docker-compose", "docker-compose.dcproj", "{072F40D5-E715-42E9-85ED-EBC72C941874}"
33+
EndProject
34+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Apps", "Apps", "{EE9918DE-CE9E-4A4E-AC9E-EB4B39259515}"
35+
EndProject
36+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventStore.App", "Apps\EventStore.App\EventStore.App.csproj", "{31065208-A0BE-4423-B054-737D7F7B5C8E}"
37+
EndProject
38+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EventConsumer.App", "Apps\EventConsumer.App\EventConsumer.App.csproj", "{9FBE60E6-7183-4F41-8FD9-322FE5FAEA2A}"
39+
EndProject
40+
Global
41+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
42+
Debug|Any CPU = Debug|Any CPU
43+
Release|Any CPU = Release|Any CPU
44+
EndGlobalSection
45+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
46+
{21A1F367-48AC-4820-80EC-F0C9B21006BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{21A1F367-48AC-4820-80EC-F0C9B21006BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{21A1F367-48AC-4820-80EC-F0C9B21006BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
49+
{21A1F367-48AC-4820-80EC-F0C9B21006BE}.Release|Any CPU.Build.0 = Release|Any CPU
50+
{51F06C26-E2E1-4918-88EE-6C81ABD3D86A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51+
{51F06C26-E2E1-4918-88EE-6C81ABD3D86A}.Debug|Any CPU.Build.0 = Debug|Any CPU
52+
{51F06C26-E2E1-4918-88EE-6C81ABD3D86A}.Release|Any CPU.ActiveCfg = Release|Any CPU
53+
{51F06C26-E2E1-4918-88EE-6C81ABD3D86A}.Release|Any CPU.Build.0 = Release|Any CPU
54+
{3C65B94C-6B47-4E84-A970-AEF8B3155556}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55+
{3C65B94C-6B47-4E84-A970-AEF8B3155556}.Debug|Any CPU.Build.0 = Debug|Any CPU
56+
{3C65B94C-6B47-4E84-A970-AEF8B3155556}.Release|Any CPU.ActiveCfg = Release|Any CPU
57+
{3C65B94C-6B47-4E84-A970-AEF8B3155556}.Release|Any CPU.Build.0 = Release|Any CPU
58+
{DEE4082B-FE21-43F9-AF98-D0FF1EB03215}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59+
{DEE4082B-FE21-43F9-AF98-D0FF1EB03215}.Debug|Any CPU.Build.0 = Debug|Any CPU
60+
{DEE4082B-FE21-43F9-AF98-D0FF1EB03215}.Release|Any CPU.ActiveCfg = Release|Any CPU
61+
{DEE4082B-FE21-43F9-AF98-D0FF1EB03215}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{12CBC3CD-E73C-4A6E-BF6C-DFCEDAFF5DA7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{12CBC3CD-E73C-4A6E-BF6C-DFCEDAFF5DA7}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{12CBC3CD-E73C-4A6E-BF6C-DFCEDAFF5DA7}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{12CBC3CD-E73C-4A6E-BF6C-DFCEDAFF5DA7}.Release|Any CPU.Build.0 = Release|Any CPU
66+
{0D913F07-17CC-4BC8-A471-FA25A5AEAF83}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
67+
{0D913F07-17CC-4BC8-A471-FA25A5AEAF83}.Debug|Any CPU.Build.0 = Debug|Any CPU
68+
{0D913F07-17CC-4BC8-A471-FA25A5AEAF83}.Release|Any CPU.ActiveCfg = Release|Any CPU
69+
{0D913F07-17CC-4BC8-A471-FA25A5AEAF83}.Release|Any CPU.Build.0 = Release|Any CPU
70+
{A2006E94-6521-43CC-8904-6BAA9AFAF3F9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71+
{A2006E94-6521-43CC-8904-6BAA9AFAF3F9}.Debug|Any CPU.Build.0 = Debug|Any CPU
72+
{A2006E94-6521-43CC-8904-6BAA9AFAF3F9}.Release|Any CPU.ActiveCfg = Release|Any CPU
73+
{A2006E94-6521-43CC-8904-6BAA9AFAF3F9}.Release|Any CPU.Build.0 = Release|Any CPU
74+
{01339E7C-83FA-423F-B2AB-46D88BDCEE59}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
75+
{01339E7C-83FA-423F-B2AB-46D88BDCEE59}.Debug|Any CPU.Build.0 = Debug|Any CPU
76+
{01339E7C-83FA-423F-B2AB-46D88BDCEE59}.Release|Any CPU.ActiveCfg = Release|Any CPU
77+
{01339E7C-83FA-423F-B2AB-46D88BDCEE59}.Release|Any CPU.Build.0 = Release|Any CPU
78+
{072F40D5-E715-42E9-85ED-EBC72C941874}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
79+
{072F40D5-E715-42E9-85ED-EBC72C941874}.Debug|Any CPU.Build.0 = Debug|Any CPU
80+
{072F40D5-E715-42E9-85ED-EBC72C941874}.Release|Any CPU.ActiveCfg = Release|Any CPU
81+
{072F40D5-E715-42E9-85ED-EBC72C941874}.Release|Any CPU.Build.0 = Release|Any CPU
82+
{31065208-A0BE-4423-B054-737D7F7B5C8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
83+
{31065208-A0BE-4423-B054-737D7F7B5C8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
84+
{31065208-A0BE-4423-B054-737D7F7B5C8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
85+
{31065208-A0BE-4423-B054-737D7F7B5C8E}.Release|Any CPU.Build.0 = Release|Any CPU
86+
{9FBE60E6-7183-4F41-8FD9-322FE5FAEA2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
87+
{9FBE60E6-7183-4F41-8FD9-322FE5FAEA2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
88+
{9FBE60E6-7183-4F41-8FD9-322FE5FAEA2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
89+
{9FBE60E6-7183-4F41-8FD9-322FE5FAEA2A}.Release|Any CPU.Build.0 = Release|Any CPU
90+
EndGlobalSection
91+
GlobalSection(SolutionProperties) = preSolution
92+
HideSolutionNode = FALSE
93+
EndGlobalSection
94+
GlobalSection(NestedProjects) = preSolution
95+
{21A1F367-48AC-4820-80EC-F0C9B21006BE} = {066150CB-B616-4E5B-A04A-C7ECDDC778FE}
96+
{51F06C26-E2E1-4918-88EE-6C81ABD3D86A} = {10DA4914-9BFF-42BA-8931-003C95F4D0DB}
97+
{3C65B94C-6B47-4E84-A970-AEF8B3155556} = {10DA4914-9BFF-42BA-8931-003C95F4D0DB}
98+
{18272749-A72B-4A60-9961-F7225A594340} = {7912080D-1F02-42E0-A440-AC2713C92603}
99+
{0E046BF8-EF83-4F06-9EE7-A72399D7BBFD} = {7912080D-1F02-42E0-A440-AC2713C92603}
100+
{12CBC3CD-E73C-4A6E-BF6C-DFCEDAFF5DA7} = {18272749-A72B-4A60-9961-F7225A594340}
101+
{0D913F07-17CC-4BC8-A471-FA25A5AEAF83} = {0E046BF8-EF83-4F06-9EE7-A72399D7BBFD}
102+
{A2006E94-6521-43CC-8904-6BAA9AFAF3F9} = {18272749-A72B-4A60-9961-F7225A594340}
103+
{01339E7C-83FA-423F-B2AB-46D88BDCEE59} = {0E046BF8-EF83-4F06-9EE7-A72399D7BBFD}
104+
{31065208-A0BE-4423-B054-737D7F7B5C8E} = {EE9918DE-CE9E-4A4E-AC9E-EB4B39259515}
105+
{9FBE60E6-7183-4F41-8FD9-322FE5FAEA2A} = {EE9918DE-CE9E-4A4E-AC9E-EB4B39259515}
106+
EndGlobalSection
107+
GlobalSection(ExtensibilityGlobals) = postSolution
108+
SolutionGuid = {52EDEB14-AB9F-4E0E-B383-74D4ABE66B38}
109+
EndGlobalSection
110+
EndGlobal
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="EventFlow.AspNetCore" Version="0.77.4077" />
10+
<PackageReference Include="EventFlow.DependencyInjection" Version="0.77.4077" />
11+
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.3" />
12+
</ItemGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\..\Domain\Domain.csproj" />
16+
<ProjectReference Include="..\..\Infrastructures\Infrastructure\Infrastructure.csproj" />
17+
</ItemGroup>
18+
19+
</Project>

Apps/EventConsumer.App/Program.cs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
using Domain.Business.Movies;
2+
using Domain.Business.Movies.Events;
3+
using Domain.Module;
4+
using EventFlow;
5+
using EventFlow.Aggregates;
6+
using EventFlow.AspNetCore.Extensions;
7+
using EventFlow.Configuration;
8+
using EventFlow.DependencyInjection.Extensions;
9+
using EventFlow.Extensions;
10+
using EventFlow.RabbitMQ;
11+
using EventFlow.RabbitMQ.Extensions;
12+
using EventFlow.Subscribers;
13+
using Infrastructure.Configurations;
14+
using Infrastructure.RabbitMq;
15+
using Microsoft.Extensions.Configuration;
16+
using Microsoft.Extensions.DependencyInjection;
17+
using Microsoft.Extensions.Hosting;
18+
using System;
19+
using System.IO;
20+
using System.Threading;
21+
using System.Threading.Tasks;
22+
23+
namespace EventConsumer.App
24+
{
25+
public class Program
26+
{
27+
28+
public static async Task Main(string[] args)
29+
{
30+
var builder = new HostBuilder()
31+
.ConfigureAppConfiguration((host, config) =>
32+
{
33+
config.SetBasePath(Directory.GetCurrentDirectory());
34+
config.AddJsonFile("appsettings.json", true, true);
35+
config.AddJsonFile($"appsettings.{host.HostingEnvironment.EnvironmentName}.json", true, true);
36+
config.AddEnvironmentVariables();
37+
})
38+
.ConfigureServices(
39+
(hostcontext, services) =>
40+
{
41+
var envconfig = EnvironmentConfiguration.Bind(hostcontext.Configuration);
42+
services.AddSingleton(envconfig);
43+
44+
EventFlowOptions.New
45+
.Configure(cfg => cfg.IsAsynchronousSubscribersEnabled = true)
46+
.UseServiceCollection(services)
47+
.AddAspNetCore()
48+
.PublishToRabbitMq(RabbitMqConfiguration.With(new Uri($"{envconfig.RabbitMqConnection}"),
49+
true, 5, envconfig.RabbitExchange))
50+
.RegisterModule<DomainModule>()
51+
52+
.AddAsynchronousSubscriber<MovieAggregate, MovieId, MovieCreatedEvent, RabbitMqConsumePersistanceService>()
53+
.RegisterServices(s =>
54+
{
55+
s.Register<IHostedService, RabbitConsumePersistenceService>(Lifetime.Singleton);
56+
s.Register<IHostedService, RabbitMqConsumePersistanceService>(Lifetime.Singleton);
57+
});
58+
})
59+
.ConfigureLogging((hostingContext, logging) => { });
60+
61+
await builder.RunConsoleAsync();
62+
}
63+
64+
}
65+
66+
public interface IRabbitMqConsumerPersistanceService
67+
{
68+
69+
}
70+
71+
public class RabbitMqConsumePersistanceService : IHostedService, IRabbitMqConsumerPersistanceService, ISubscribeAsynchronousTo<MovieAggregate, MovieId, MovieCreatedEvent>
72+
{
73+
74+
public Task StartAsync(CancellationToken cancellationToken)
75+
{
76+
return Task.CompletedTask;
77+
}
78+
79+
public Task StopAsync(CancellationToken cancellationToken)
80+
{
81+
return Task.CompletedTask;
82+
}
83+
84+
public Task HandleAsync(IDomainEvent<MovieAggregate, MovieId, MovieCreatedEvent> @event, CancellationToken cancellationToken)
85+
{
86+
87+
Console.WriteLine($"Movie created {@event.AggregateEvent.Movie.Title}");
88+
89+
return Task.CompletedTask;
90+
}
91+
92+
}
93+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"ASPNETCORE_ENVIRONMENT": "Development",
3+
"ES_CONNECTION": "Server=localhost,5553;Database=event_sourcing;UserId=sa;Password=Pass@word",
4+
"DB_CONNECTION": "Server=localhost,5553;Database=accounts;User Id=sa;Password=Pass@word",
5+
"RABBIT_CONNECTION": "amqp://test:test@localhost",
6+
"RABBIT_EXCHANGE": "eventflow",
7+
"RABBIT_QUEUE": "eventconsumer",
8+
"SERVICE_NAME": "rabbitconsumer"
9+
}

Apps/EventStore.App/Dockerfile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS base
2+
WORKDIR /app
3+
4+
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build
5+
WORKDIR /src
6+
COPY ["Apps/EventStore.App/EventStore.App.csproj", "Apps/EventStore.App/"]
7+
COPY ["Infrastructures/EventStore.Middleware/EventStore.Middleware.csproj", "Infrastructures/EventStore.Middleware/"]
8+
COPY ["Infrastructures/Infrastructure/Infrastructure.csproj", "Infrastructures/Infrastructure/"]
9+
RUN dotnet restore "Apps/EventStore.App/EventStore.App.csproj"
10+
COPY . .
11+
WORKDIR "/src/Apps/EventStore.App"
12+
RUN dotnet build "EventStore.App.csproj" -c Release -o /app
13+
14+
FROM build AS publish
15+
RUN dotnet publish "EventStore.App.csproj" -c Release -o /app
16+
17+
FROM base AS final
18+
WORKDIR /app
19+
COPY --from=publish /app .
20+
ENTRYPOINT ["dotnet", "EventStore.App.dll"]
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp3.1</TargetFramework>
5+
<OutputType>Exe</OutputType>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<PackageReference Include="EventFlow" Version="0.77.4077" />
10+
<PackageReference Include="EventFlow.AspNetCore" Version="0.77.4077" />
11+
<PackageReference Include="EventFlow.DependencyInjection" Version="0.77.4077" />
12+
<PackageReference Include="EventFlow.EntityFramework" Version="0.77.4077" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\..\Infrastructures\EventStore.Middleware\EventStore.Middleware.csproj" />
17+
<ProjectReference Include="..\..\Infrastructures\Infrastructure\Infrastructure.csproj" />
18+
</ItemGroup>
19+
20+
</Project>

Apps/EventStore.App/Program.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
using Microsoft.AspNetCore.Hosting;
2+
using Microsoft.Extensions.Configuration;
3+
using System;
4+
using System.Net;
5+
6+
namespace EventStore.App
7+
{
8+
internal class Program
9+
{
10+
private static void Main(string[] args)
11+
{
12+
Console.WriteLine("Event store setting up for Event Sourcing");
13+
14+
try
15+
{
16+
var config = new ConfigurationBuilder()
17+
.AddCommandLine(args)
18+
.AddEnvironmentVariables()
19+
.AddJsonFile("appsettings.json", true, true)
20+
.Build();
21+
22+
var builder = new WebHostBuilder()
23+
.UseConfiguration(config)
24+
.UseStartup<Startup>()
25+
.UseKestrel(options =>
26+
{
27+
options.Listen(IPAddress.Any, 80);
28+
});
29+
30+
var host = builder.Build();
31+
host.Run();
32+
}
33+
catch (Exception)
34+
{
35+
}
36+
finally
37+
{
38+
Console.WriteLine("Event store is UP now!!");
39+
}
40+
}
41+
}
42+
}

0 commit comments

Comments
 (0)