|
1 | | -# AzureServiceBusEmulator.Configuration |
2 | | -A Library to help build Azure Service Bus configuration files |
| 1 | +## AzureServiceBusEmulator.Configuration Package |
| 2 | + |
| 3 | +This library contains a library that can be used to programaticaly generate Configuration files for [Azure Service Bus Emulator](https://learn.microsoft.com/en-us/azure/service-bus-messaging/overview-emulator) so that they can be used for local development setups. |
| 4 | + |
| 5 | +### The Configuration Builder |
| 6 | +The configuration Builder `AsbEmulatorConfigurationBuilder` is the entry-point into this project |
| 7 | + |
| 8 | +The Create configuration for a Namespace with two Queues and a Topic |
| 9 | + |
| 10 | +```csharp |
| 11 | +var asbEmulatorConfig = AsbEmulatorConfigurationBuilder.WithNamespace("local", nOptions => |
| 12 | + nOptions.WithQueue("Queue1") |
| 13 | + .WithQueue("Queue2") |
| 14 | + .WithTopic("Topic1", tOptions => |
| 15 | + tOptions.WithSubscription("Subscription1") |
| 16 | + .WithSubscription("Subscription2")) |
| 17 | + ).Build(); |
| 18 | + |
| 19 | +File.WriteAllText("Config.json", JsonSerializer.Serialize(asbEmulatorConfig, new JsonSerializerOptions() { WriteIndented = true })); |
| 20 | +``` |
| 21 | + |
| 22 | +This will produce the following Config file: |
| 23 | + |
| 24 | +```json |
| 25 | +{ |
| 26 | + "UserConfig" : { |
| 27 | + "Namespaces" : [ { |
| 28 | + "Name" : "local", |
| 29 | + "Queues" : [ { |
| 30 | + "Name" : "Queue1", |
| 31 | + "Properties" : { |
| 32 | + "DeadLetteringOnMessageExpiration" : false, |
| 33 | + "DefaultMessageTimeToLive" : "PT1H", |
| 34 | + "DuplicateDetectionHistoryTimeWindow" : "PT20S", |
| 35 | + "ForwardDeadLetteredMessagesTo" : "", |
| 36 | + "ForwardTo" : "", |
| 37 | + "LockDuration" : "PT1M", |
| 38 | + "MaxDeliveryCount" : 3, |
| 39 | + "RequiresDuplicateDetection" : false, |
| 40 | + "RequiresSession" : false |
| 41 | + } |
| 42 | + }, { |
| 43 | + "Name" : "Queue2", |
| 44 | + "Properties" : { |
| 45 | + "DeadLetteringOnMessageExpiration" : false, |
| 46 | + "DefaultMessageTimeToLive" : "PT1H", |
| 47 | + "DuplicateDetectionHistoryTimeWindow" : "PT20S", |
| 48 | + "ForwardDeadLetteredMessagesTo" : "", |
| 49 | + "ForwardTo" : "", |
| 50 | + "LockDuration" : "PT1M", |
| 51 | + "MaxDeliveryCount" : 3, |
| 52 | + "RequiresDuplicateDetection" : false, |
| 53 | + "RequiresSession" : false |
| 54 | + } |
| 55 | + } ], |
| 56 | + "Topics" : [ { |
| 57 | + "Name" : "Topic1", |
| 58 | + "Properties" : { |
| 59 | + "DefaultMessageTimeToLive" : "PT1H", |
| 60 | + "DuplicateDetectionHistoryTimeWindow" : "PT20S", |
| 61 | + "RequiresDuplicateDetection" : false |
| 62 | + }, |
| 63 | + "Subscriptions" : [ { |
| 64 | + "Name" : "Subscription1", |
| 65 | + "Properties" : { |
| 66 | + "DeadLetteringOnMessageExpiration" : false, |
| 67 | + "DefaultMessageTimeToLive" : "PT1H", |
| 68 | + "DuplicateDetectionHistoryTimeWindow" : "PT20S", |
| 69 | + "ForwardDeadLetteredMessagesTo" : "", |
| 70 | + "ForwardTo" : "", |
| 71 | + "LockDuration" : "PT1M", |
| 72 | + "MaxDeliveryCount" : 3, |
| 73 | + "RequiresDuplicateDetection" : false, |
| 74 | + "RequiresSession" : false |
| 75 | + }, |
| 76 | + "Rules" : [ ] |
| 77 | + }, { |
| 78 | + "Name" : "Subscription2", |
| 79 | + "Properties" : { |
| 80 | + "DeadLetteringOnMessageExpiration" : false, |
| 81 | + "DefaultMessageTimeToLive" : "PT1H", |
| 82 | + "DuplicateDetectionHistoryTimeWindow" : "PT20S", |
| 83 | + "ForwardDeadLetteredMessagesTo" : "", |
| 84 | + "ForwardTo" : "", |
| 85 | + "LockDuration" : "PT1M", |
| 86 | + "MaxDeliveryCount" : 3, |
| 87 | + "RequiresDuplicateDetection" : false, |
| 88 | + "RequiresSession" : false |
| 89 | + }, |
| 90 | + "Rules" : [ ] |
| 91 | + } ] |
| 92 | + } ] |
| 93 | + } ], |
| 94 | + "Logging" : { |
| 95 | + "Type" : "File" |
| 96 | + } |
| 97 | + } |
| 98 | +} |
| 99 | +``` |
| 100 | + |
| 101 | +### Samples |
| 102 | + - [ASBExample](samples/ASBExample/Readme.md) : This is a Basic Example the that generates the ASB Emulator Config file based on all Topics that it knows about. |
0 commit comments