Skip to content

Commit b5c8362

Browse files
Merge pull request #46 from TransactionProcessing/task/#43_reduceeventsize
Updates to useage of worker service
2 parents 52e6d1f + 91622f9 commit b5c8362

File tree

9 files changed

+53
-12
lines changed

9 files changed

+53
-12
lines changed

MessagingService.Client/MessagingService.Client.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="ClientProxyBase" Version="1.0.3.3" />
9+
<PackageReference Include="ClientProxyBase" Version="1.0.3.6" />
1010
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
1111
</ItemGroup>
1212

MessagingService.EmailAggregate.Tests/MessagingService.EmailAggregate.Tests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
<ItemGroup>
1010
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
11-
<PackageReference Include="Shared.EventStore" Version="1.0.3.3" />
11+
<PackageReference Include="Shared.EventStore" Version="1.0.3.6" />
1212
<PackageReference Include="Shouldly" Version="4.0.3" />
1313
<PackageReference Include="xunit" Version="2.4.1" />
1414
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">

MessagingService.EmailMessage.DomainEvents/MessagingService.EmailMessage.DomainEvents.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Shared" Version="1.0.3.3" />
9-
<PackageReference Include="Shared.DomainDrivenDesign" Version="1.0.3.3" />
8+
<PackageReference Include="Shared" Version="1.0.3.6" />
9+
<PackageReference Include="Shared.DomainDrivenDesign" Version="1.0.3.6" />
1010
</ItemGroup>
1111

1212
</Project>

MessagingService.EmailMessageAggregate/MessagingService.EmailMessageAggregate.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Shared" Version="1.0.3.3" />
9-
<PackageReference Include="Shared.EventStore" Version="1.0.3.3" />
8+
<PackageReference Include="Shared" Version="1.0.3.6" />
9+
<PackageReference Include="Shared.EventStore" Version="1.0.3.6" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="ClientProxyBase" Version="1.0.3.3" />
10+
<PackageReference Include="ClientProxyBase" Version="1.0.3.6" />
1111
<PackageReference Include="Ductus.FluentDocker" Version="2.7.3" />
1212
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
1313
<PackageReference Include="SecurityService.Client" Version="1.0.5" />
14-
<PackageReference Include="Shared.IntegrationTesting" Version="1.0.3.3" />
14+
<PackageReference Include="Shared.IntegrationTesting" Version="1.0.3.6" />
1515
<PackageReference Include="Shouldly" Version="4.0.3" />
1616
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.5.14" />
1717
<PackageReference Include="SpecFlow.xUnit" Version="3.5.14" />

MessagingService.SMSMessage.DomainEvents/MessagingService.SMSMessage.DomainEvents.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Shared.DomainDrivenDesign" Version="1.0.3.3" />
8+
<PackageReference Include="Shared.DomainDrivenDesign" Version="1.0.3.6" />
99
</ItemGroup>
1010

1111
</Project>

MessagingService.SMSMessageAggregate/MessagingService.SMSMessageAggregate.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</PropertyGroup>
66

77
<ItemGroup>
8-
<PackageReference Include="Shared.EventStore" Version="1.0.3.3" />
8+
<PackageReference Include="Shared.EventStore" Version="1.0.3.6" />
99
</ItemGroup>
1010

1111
<ItemGroup>

MessagingService/MessagingService.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.2" />
1212
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.2" />
1313
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
14-
<PackageReference Include="Shared" Version="1.0.3.3" />
14+
<PackageReference Include="Shared" Version="1.0.3.6" />
1515
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.2.0" />
1616
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="4.2.0" />
1717
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />

MessagingService/Program.cs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,14 @@
1111
namespace MessagingService
1212
{
1313
using System.Diagnostics.CodeAnalysis;
14+
using System.Net.Http;
1415
using EmailMessage.DomainEvents;
1516
using EventStore.Client;
1617
using Microsoft.Extensions.DependencyInjection;
1718
using Shared.EventStore.Aggregate;
19+
using Shared.EventStore.EventHandling;
1820
using Shared.EventStore.Subscriptions;
21+
using Shared.Logger;
1922
using SMSMessage.DomainEvents;
2023

2124
[ExcludeFromCodeCoverage]
@@ -56,10 +59,48 @@ public static IHostBuilder CreateHostBuilder(string[] args)
5659

5760
TypeProvider.LoadDomainEventsTypeDynamically();
5861

59-
services.AddHostedService<SubscriptionWorker>();
62+
services.AddHostedService<SubscriptionWorker>(provider =>
63+
{
64+
IDomainEventHandlerResolver r =
65+
provider.GetRequiredService<IDomainEventHandlerResolver>();
66+
EventStorePersistentSubscriptionsClient p = provider.GetRequiredService<EventStorePersistentSubscriptionsClient>();
67+
HttpClient h = provider.GetRequiredService<HttpClient>();
68+
SubscriptionWorker worker = new SubscriptionWorker(r, p, h);
69+
worker.TraceGenerated += Worker_TraceGenerated;
70+
return worker;
71+
});
6072
});
6173
return hostBuilder;
6274
}
6375

76+
/// <summary>
77+
/// Workers the trace generated.
78+
/// </summary>
79+
/// <param name="trace">The trace.</param>
80+
/// <param name="logLevel">The log level.</param>
81+
private static void Worker_TraceGenerated(string trace, LogLevel logLevel)
82+
{
83+
switch (logLevel)
84+
{
85+
case LogLevel.Trace:
86+
Logger.LogTrace(trace);
87+
break;
88+
case LogLevel.Debug:
89+
Logger.LogDebug(trace);
90+
break;
91+
case LogLevel.Information:
92+
Logger.LogInformation(trace);
93+
break;
94+
case LogLevel.Warning:
95+
Logger.LogWarning(trace);
96+
break;
97+
case LogLevel.Error:
98+
Logger.LogError(new Exception(trace));
99+
break;
100+
case LogLevel.Critical:
101+
Logger.LogCritical(new Exception(trace));
102+
break;
103+
}
104+
}
64105
}
65106
}

0 commit comments

Comments
 (0)