-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
39 lines (31 loc) · 1.39 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
using Azure.Messaging.ServiceBus;
using Azure.Messaging.ServiceBus.Administration;
using Definit.Results;
using FluentServiceBus;
using Sample;
var connectionString = "";
var sender = await Build(connectionString);
await sender.Publish(new { Message = "TestMessage" }, "test-topic");
static async Task<IRouterPublisher> Build(string connectionString)
{
var client = new ServiceBusClient(connectionString);
var administrationClient = new ServiceBusAdministrationClient(connectionString);
var built = await new ServiceBusBuilder()
.AddQueue(new QueueName("test-queue"))
.AddPublisher(out var testQueueSender)
.WithConsumer<Message>(message => Result.Or<Abandon>.Success)
.AddTopic(new TopicName("test-topic"))
.AddPublisher(out var testTopicSender)
.AddSubscription(new SubscriptionName("test-subscription"))
.AddSubscription(new SubscriptionName("test-subscription-2"))
.WithConsumer<Message>(message => Result.Or<Abandon>.Success)
.AddQueue(new QueueName("test-qeueue-2"))
.BuildRouterWithStore(client, administrationClient);
await testQueueSender.GetSender(built).Publish(new { Message = "TestQueueMessage" });
await testTopicSender.GetSender(built).Publish(new { Message = "TestTopicMessage" });
return built.Router;
}
namespace Sample
{
public sealed record Message();
}