-
Notifications
You must be signed in to change notification settings - Fork 9
/
Program.cs
37 lines (36 loc) · 1.54 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
using OpenTelemetryExample;
using OpenTelemetryExample.Model;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Motor.Extensions.Conversion.SystemJson;
using Motor.Extensions.Hosting.Abstractions;
using Motor.Extensions.Hosting.Consumer;
using Motor.Extensions.Hosting.Publisher;
using Motor.Extensions.Hosting.RabbitMQ;
using Motor.Extensions.Utilities;
await MotorHost.CreateDefaultBuilder()
// Configure the types of the input and output messages
.ConfigureSingleOutputService<InputMessage, OutputMessage>()
.ConfigureServices((_, services) =>
{
// Add a handler for the input message which returns an output message
// This handler is called for every new incoming message
services.AddTransient<ISingleOutputService<InputMessage, OutputMessage>, SingleOutputService>();
})
// Add the incomming communication module.
.ConfigureConsumer<InputMessage>((_, builder) =>
{
// In this case the messages are received from RabbitMQ
builder.AddRabbitMQ();
// The encoding of the incoming message, such that the handler is able to deserialize the message
builder.AddSystemJson();
})
// Add the outgoing communication module.
.ConfigurePublisher<OutputMessage>((_, builder) =>
{
// In this case the messages are send to RabbitMQ
builder.AddRabbitMQ();
// The encoding of the outgoing message, such that the handler is able to serialize the message
builder.AddSystemJson();
})
.RunConsoleAsync();