FluentServiceBus is an library aiming to help setup Azure ServiceBus using an Fluent/LINQ like API.
var client = new ServiceBusClient(connectionString);
var administrationClient = new ServiceBusAdministrationClient(connectionString);
await new ServiceBusBuilder()
.AddQueue(new QueueName("test-queue"))
.Build(client, administrationClient);
new ServiceBusBuilder()
.AddTopic(new TopicName("test-topic"))
.AddSubscription(new SubscriptionName("test-subscription"))
.AddSubscription(new SubscriptionName("test-subscription-2"))
new ServiceBusBuilder()
.AddQueue(new QueueName("test-queue"))
.WithConsumer<Message>(message => Result.Or<Abandon>.Success)
.AddTopic(new TopicName("test-topic"))
.AddSubscription(new SubscriptionName("test-subscription"))
.WithConsumer<Message>(message => Result.Or<Abandon>.Success)
.AddSubscription(new SubscriptionName("test-subscription-2"))
.WithConsumer<Message>(message => Result.Or<Abandon>.Success)
var built = await new ServiceBusBuilder()
.AddQueue(new QueueName("test-queue"))
.AddPublisher(out var testQueueSender)
.AddTopic(new TopicName("test-topic"))
.AddPublisher(out var testTopicSender)
.AddSubscription(new SubscriptionName("test-subscription"))
.Build(client, administrationClient);
await testQueueSender.GetSender(built).Publish(new { Message = "TestQueueMessage" });
await testTopicSender.GetSender(built).Publish(new { Message = "TestTopicMessage" });
var router = await new ServiceBusBuilder()
.AddQueue(new QueueName("test-queue"))
.WithConsumer<Message>(message => Result.Or<Abandon>.Success)
.AddTopic(new TopicName("test-topic"))
.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)
.Router;
await router.Publish(new { Message = "TestMessage" }, "test-topic");
The code in this repo is licensed under the MIT license.