Skip to content

Commit 2767924

Browse files
Description for hierarchy-namespace-escape sample
1 parent 8c88114 commit 2767924

File tree

3 files changed

+35
-13
lines changed

3 files changed

+35
-13
lines changed

samples/azure-service-bus-netstandard/hierarchy-namespace-escape/ASBS_6/Endpoint1/Program.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@
1818
}
1919

2020
var transport = new AzureServiceBusTransport(connectionString, TopicTopology.Default);
21+
#region namespaceOptions
2122
transport.HierarchyNamespaceOptions = new HierarchyNamespaceOptions { HierarchyNamespace = "my-hierarchy" };
23+
#endregion
24+
#region excludedMessage
2225
transport.HierarchyNamespaceOptions.ExcludeMessageType<MessageExcluded>();
26+
#endregion
2327
endpointConfiguration.UseTransport(transport);
2428
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
2529

samples/azure-service-bus-netstandard/hierarchy-namespace-escape/sample.md

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ summary: Demonstrates how to escape a hierarchy namespace with Azure Service Bus
44
reviewed: 2026-02-05
55
component: ASBS
66
related:
7-
- transports/azure-service-bus
7+
- transports/azure-service-bus/configuration
88
---
99

1010
## Prerequisites
@@ -13,19 +13,34 @@ include: asb-connectionstring-xplat
1313

1414
## Code walk-through
1515

16-
This sample shows a basic two-endpoint scenario exchanging messages with each other so that:
16+
This sample shows a usage of hierarchy namespace with Azure Service Bus with a hierarchy escape mechanism included. Note the following line in the configuration for `Endpoint1`:
1717

18-
* `Endpoint1` sends a `Message1` message to `Endpoint2`.
19-
* `Endpoint2` replies to `Endpoint1` with a `Message2` instance.
18+
snippet: excludedMessage
19+
20+
This makes sure that sending a message of a type `MessageExcluded` does not take hierarchy (`my-hierarchy`) into consideration.
21+
22+
Pressing `2` tries sending a message (of the `MessageExcluded` type) to `Endpoint2`. This endpoint is included in the hierarchy, but the escape mechanism excludes this type of a message. Effectively, the message is tried to be sent to `Samples.ASBS.HierarchyNamespaceEscape.Endpoint2`. Such an endpoint doesn't exist. This is why this attempts ends with an exception: `Azure.Messaging.ServiceBus.ServiceBusException: Put token failed. status-code: 404, status-description: The messaging entity 'sb://xxx.servicebus.windows.net/Samples.ASBS.HierarchyNamespaceEscape.Endpoint2' could not be found.`.
23+
24+
Pressing `3` sends a message of the same type to `Endpoint3`. This endpoint is not included in the hierarchy. This is why this attempts succeeds.
2025

2126
### Transport configuration
2227

2328
snippet: config
2429

30+
Two endpoints (`Endpoint1` and `Endpoint2` are configured to be included in the hierarchy `my-hierarchy`). `Endpoint3` is not included in the hierarchy.
31+
32+
snippet: namespaceOptions
33+
34+
This means that the endpoints will be effectively:
35+
* `Endpoint1`: `my-hierarchy/Samples.ASBS.HierarchyNamespaceEscape.Endpoint1`
36+
* `Endpoint2`: `my-hierarchy/Samples.ASBS.HierarchyNamespaceEscape.Endpoint2`
37+
* `Endpoint3`: `Samples.ASBS.HierarchyNamespaceEscape.Endpoint3`
38+
2539
## Viewing messages in-flight
2640

2741
The following queues for the two endpoints can be seen in the Azure Portal or a third-party tool:
2842

29-
* `samples.asbs.sendreply.endpoint1`
30-
* `samples.asbs.sendreply.endpoint2`
43+
* `my-hierarchy/samples.asbs.hierarchynamespaceescape.endpoint1`
44+
* `my-hierarchy/samples.asbs.hierarchynamespaceescape.endpoint2`
45+
* `samples.asbs.hierarchynamespaceescape.endpoint3`
3146
* `error`

samples/azure-service-bus-netstandard/hierarchy-namespace/sample.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,7 @@ include: asb-connectionstring-xplat
1313

1414
## Code walk-through
1515

16-
This sample shows a usage of hierarchy namespace with Azure Service Bus. Both endpoints (`Endpoint1` and `Endpoint2`) are configured using `HierarchyNamespace`:
17-
18-
snippet: namespaceOptions
19-
20-
This means that the endpoints will be effectively:
21-
* `Endpoint1`: `my-hierarchy/Samples.ASBS.HierarchyNamespace.Endpoint1`
22-
* `Endpoint2`: `my-hierarchy/Samples.ASBS.HierarchyNamespace.Endpoint2`
16+
This sample shows a usage of hierarchy namespace with Azure Service Bus.
2317

2418
The behavior is as follows:
2519
* `Endpoint1` sends a `Message1` message to `Endpoint2`.
@@ -29,6 +23,15 @@ The behavior is as follows:
2923

3024
snippet: config
3125

26+
Both endpoints (`Endpoint1` and `Endpoint2`) are configured using `HierarchyNamespace`:
27+
28+
snippet: namespaceOptions
29+
30+
This means that the endpoints will be effectively:
31+
* `Endpoint1`: `my-hierarchy/Samples.ASBS.HierarchyNamespace.Endpoint1`
32+
* `Endpoint2`: `my-hierarchy/Samples.ASBS.HierarchyNamespace.Endpoint2`
33+
34+
3235
## Viewing messages in-flight
3336

3437
The following queues for the two endpoints can be seen in the Azure Portal or a third-party tool:

0 commit comments

Comments
 (0)