-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathProgram.cs
More file actions
44 lines (43 loc) · 1.69 KB
/
Program.cs
File metadata and controls
44 lines (43 loc) · 1.69 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
using ConsumeAndMultiOutputPublisherWithRabbitMQ;
using ConsumeAndMultiOutputPublisherWithRabbitMQ.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
.ConfigureMultiOutputService<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<IMultiOutputService<InputMessage, OutputMessage>, MultiOutputService>();
}
)
// 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();