-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathProgram.cs
45 lines (37 loc) · 2 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 MultipleDifferentTransports;
using Tingle.EventBus.Configuration;
using Tingle.EventBus.Transports.Azure.EventHubs;
using Tingle.EventBus.Transports.Azure.ServiceBus;
var host = Host.CreateDefaultBuilder(args)
.ConfigureServices((hostContext, services) =>
{
var configuration = hostContext.Configuration;
services.AddEventBus(builder =>
{
builder.Configure(o =>
{
o.DefaultTransportName = AzureServiceBusDefaults.Name;
o.ConfigureEvent<VehicleTelemetryEvent>(reg =>
{
reg.ConfigureAsIotHubEvent(configuration["IotHubEventHubName"]!)
.UseIotHubEventSerializer();
reg.TransportName = AzureEventHubsDefaults.Name; // you can also use EventTransportNameAttribute on the event type declaration
});
});
builder.AddConsumer<VehicleTelemetryEventsConsumer>();
// Transport specific configuration
builder.AddAzureEventHubsTransport(options =>
{
options.Credentials = configuration.GetConnectionString("EventHub")!;
options.BlobStorageCredentials = configuration.GetConnectionString("AzureStorage")!;
});
// Transport specific configuration
builder.AddAzureServiceBusTransport(options =>
{
options.Credentials = configuration.GetConnectionString("ServiceBus")!;
options.DefaultEntityKind = EntityKind.Queue; // required if using the basic SKU (does not support topics)
});
});
})
.Build();
await host.RunAsync();