@@ -78,7 +78,9 @@ public override async Task<TransportInfrastructure> Initialize(HostSettings host
78
78
{
79
79
TransportType = transportType ,
80
80
EnableCrossEntityTransactions = enableCrossEntityTransactions ,
81
- Identifier = $ "Client-{ receiver . Id } -{ receiver . ReceiveAddress } -{ Guid . NewGuid ( ) } ",
81
+ Identifier = HierarchyNamespace is null
82
+ ? $ "Client-{ receiver . Id } -{ receiver . ReceiveAddress } -{ Guid . NewGuid ( ) } "
83
+ : $ "Client-{ HierarchyNamespace } -{ receiver . Id } -{ receiver . ReceiveAddress } -{ Guid . NewGuid ( ) } ",
82
84
} ;
83
85
ApplyRetryPolicyOptionsIfNeeded ( receiveClientOptions ) ;
84
86
ApplyWebProxyIfNeeded ( receiveClientOptions ) ;
@@ -93,7 +95,9 @@ public override async Task<TransportInfrastructure> Initialize(HostSettings host
93
95
TransportType = transportType ,
94
96
// for the default client we never want things to automatically use cross entity transaction
95
97
EnableCrossEntityTransactions = false ,
96
- Identifier = $ "Client-{ hostSettings . Name } -{ Guid . NewGuid ( ) } "
98
+ Identifier = HierarchyNamespace is null
99
+ ? $ "Client-{ hostSettings . Name } -{ Guid . NewGuid ( ) } "
100
+ : $ "Client-{ HierarchyNamespace } -{ hostSettings . Name } -{ Guid . NewGuid ( ) } "
97
101
} ;
98
102
ApplyRetryPolicyOptionsIfNeeded ( defaultClientOptions ) ;
99
103
ApplyWebProxyIfNeeded ( defaultClientOptions ) ;
@@ -105,7 +109,7 @@ public override async Task<TransportInfrastructure> Initialize(HostSettings host
105
109
? new ServiceBusAdministrationClient ( FullyQualifiedNamespace , TokenCredential )
106
110
: new ServiceBusAdministrationClient ( ConnectionString ) ;
107
111
108
- var infrastructure = new AzureServiceBusTransportInfrastructure ( this , hostSettings , receiveSettingsAndClientPairs , defaultClient , administrationClient ) ;
112
+ var infrastructure = new AzureServiceBusTransportInfrastructure ( this , hostSettings , receiveSettingsAndClientPairs , defaultClient , administrationClient , HierarchyNamespace ) ;
109
113
110
114
if ( hostSettings . SetupInfrastructure )
111
115
{
@@ -114,7 +118,7 @@ await administrationClient.AssertNamespaceManageRightsAvailable(cancellationToke
114
118
115
119
var allQueues = infrastructure . Receivers
116
120
. Select ( r => r . Value . ReceiveAddress )
117
- . Concat ( sendingAddresses )
121
+ . Concat ( sendingAddresses . Select ( s => HierarchyNamespace is null || s . StartsWith ( HierarchyNamespace ) ? s : $ " { HierarchyNamespace } / { s } " ) )
118
122
. ToArray ( ) ;
119
123
120
124
var queueCreator = new TopologyCreator ( this ) ;
@@ -193,6 +197,13 @@ internal set
193
197
194
198
TopicTopology topology ;
195
199
200
+ /// <summary>
201
+ /// Specifies the value that will be prepended to every entity name referenced by the endpoint.
202
+ /// This will ensure that all entities will be part of the <see href="https://learn.microsoft.com/en-us/rest/api/servicebus/addressing-and-protocol">same hierarchy</see>
203
+ /// within the ServiceBus namespace.
204
+ /// </summary>
205
+ public string ? HierarchyNamespace { get ; set ; }
206
+
196
207
/// <summary>
197
208
/// The maximum size used when creating queues and topics in GB.
198
209
/// </summary>
0 commit comments