-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathProgram.cs
More file actions
40 lines (37 loc) · 1.56 KB
/
Program.cs
File metadata and controls
40 lines (37 loc) · 1.56 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
using CloudNimble.SimpleMessageBus.Core;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
namespace SimpleMessageBus.Samples.AzureWebJobs
{
class Program
{
static void Main(string[] args)
{
var builder = Host.CreateDefaultBuilder()
// RWM: Configure the services *before* you call Use____QueueProcessor so that the assembly is loaded into memory before the WebJobs' Reflection happens.
.ConfigureServices((hostContext, services) =>
{
services.AddTimerDependencies();
services.AddSingleton<IMessageHandler, EmailMessageHandler>();
})
.UseAzureStorageQueueMessagePublisher()
.UseAzureStorageQueueProcessor(options => options.ConcurrentJobs = 1)
.UseOrderedMessageDispatcher()
.ConfigureLogging((context, b) =>
{
b.SetMinimumLevel(LogLevel.Debug);
b.AddConsole();
string instrumentationKey = context.Configuration["APPINSIGHTS_INSTRUMENTATIONKEY"];
if (!string.IsNullOrEmpty(instrumentationKey))
{
b.AddApplicationInsightsWebJobs(o => o.InstrumentationKey = instrumentationKey);
}
});
builder.UseSimpleMessageBusLifetime();
var host = builder.Build();
using (host)
host.Run();
}
}
}