-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
45 lines (34 loc) · 1.33 KB
/
Program.cs
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
using MassTransit;
using Microsoft.AspNetCore.Server.Kestrel.Core;
namespace MassTest;
public class Program
{
private static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseKestrel(opt => opt.ListenAnyIP(80, o => o.Protocols = HttpProtocols.Http1));
builder.Services.AddMassTransit(x =>
{
x.AddConsumers(typeof(Program).Assembly);
x.AddSagaStateMachine<StateMachine, StateMachineState, UpdatePoolSagaDefinition>()
.InMemoryRepository();
x.UsingInMemory((context, cfg) =>
{
cfg.ConfigureEndpoints(context);
});
});
builder.Services.AddOptions<MassTransitHostOptions>()
.Configure(options =>
{
// Waits until the bus is started before
// returning from IHostedService.StartAsync
options.WaitUntilStarted = true;
// Limits the wait time when starting the bus
options.StartTimeout = TimeSpan.FromSeconds(10);
options.StopTimeout = TimeSpan.FromSeconds(5);
}); ;
builder.Services.AddHostedService<MessageGenerator>();
var app = builder.Build();
app.Run();
}
}