-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathProgram.cs
More file actions
70 lines (60 loc) · 2.22 KB
/
Program.cs
File metadata and controls
70 lines (60 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using CloudNimble.SimpleMessageBus.Core;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using System;
using System.IO;
namespace SimpleMessageBus.Samples.OnPrem
{
/// <summary>
///
/// </summary>
public class Program
{
/// <summary>
///
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
#if netcore3_0
var builder = Host.CreateDefaultBuilder()
#else
var builder = new HostBuilder()
.UseEnvironment("Development")
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) =>
{
var env = hostingContext.HostingEnvironment;
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true);
config.AddEnvironmentVariables();
})
#endif
// RWM: Configure the services before you call Use____QueueProcessor so that the assembly is loaded into memory before the Reflection happens.
.ConfigureServices((hostContext, services) =>
{
Console.WriteLine($"SimpleMessageBus starting in the {hostContext.HostingEnvironment.EnvironmentName} Environment");
services.AddTimerDependencies();
services.AddSingleton<IMessageHandler, EmailMessageHandler>();
})
.UseFileSystemMessagePublisher()
.UseFileSystemQueueProcessor()
.UseOrderedMessageDispatcher()
.ConfigureLogging((context, b) =>
{
b.SetMinimumLevel(LogLevel.Debug);
b.AddConsole();
});
#if netcore3_0
builder.UseSimpleMessageBusLifetime();
#else
builder.UseConsoleLifetime();
#endif
var host = builder.Build();
using (host)
host.Run();
}
}
}