Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<PackageVersion Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.5" />
<PackageVersion Include="Mindscape.Raygun4Net.NetCore" Version="11.2.5" />
<PackageVersion Include="NLog.Extensions.Logging" Version="5.5.0" />
<PackageVersion Include="NServiceBus" Version="10.0.0" />
<PackageVersion Include="NServiceBus" Version="10.1.0" />
<PackageVersion Include="NServiceBus.AcceptanceTesting" Version="10.0.0" />
<PackageVersion Include="NServiceBus.AmazonSQS" Version="9.0.0" />
<PackageVersion Include="NServiceBus.CustomChecks" Version="6.0.0" />
Expand All @@ -47,7 +47,7 @@
<PackageVersion Include="NServiceBus.RabbitMQ" Version="11.0.0" />
<PackageVersion Include="NServiceBus.SagaAudit" Version="6.0.0" />
<PackageVersion Include="NServiceBus.Testing" Version="10.0.1" />
<PackageVersion Include="NServiceBus.Transport.AzureServiceBus" Version="6.0.0" />
<PackageVersion Include="NServiceBus.Transport.AzureServiceBus" Version="6.1.0" />
<PackageVersion Include="NServiceBus.Transport.AzureStorageQueues" Version="14.0.0" />
<PackageVersion Include="NServiceBus.Transport.Msmq.Sources" Version="4.0.0" />
<PackageVersion Include="NServiceBus.Transport.PostgreSql" Version="9.0.0" />
Expand Down Expand Up @@ -92,4 +92,4 @@
<GlobalPackageReference Include="Microsoft.Build.CopyOnWrite" Version="1.0.334" />
<GlobalPackageReference Include="Particular.Packaging" Version="4.5.0" />
</ItemGroup>
</Project>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public static IEnumerable<TestCaseData> SupportedConnectionStrings
//EnablePartitioning
yield return new TestCaseData("Endpoint=sb://some.endpoint.name/;EnablePartitioning=True",
new ConnectionSettings(new SharedAccessSignatureAuthentication("Endpoint=sb://some.endpoint.name/;EnablePartitioning=True"), enablePartitioning: true));
//HierarchyNamespace
yield return new TestCaseData("Endpoint=sb://some.endpoint.name/;HierarchyNamespace=my-hierarchy",
new ConnectionSettings(new SharedAccessSignatureAuthentication("Endpoint=sb://some.endpoint.name/;HierarchyNamespace=my-hierarchy"), hierarchyNamespace: "my-hierarchy"));
}
}

Expand Down Expand Up @@ -86,4 +89,4 @@ public void VerifyNotSupported(string connectionString)
Assert.Throws<Exception>(() => ConnectionStringParser.Parse(connectionString));
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ protected override AzureServiceBusTransport CreateTransport(TransportSettings tr
var transport = connectionSettings.AuthenticationMethod.CreateTransportDefinition(connectionSettings, selectedTopology);
transport.UseWebSockets = connectionSettings.UseWebSockets;
transport.EnablePartitioning = connectionSettings.EnablePartitioning;
if (!string.IsNullOrWhiteSpace(connectionSettings.HierarchyNamespace))
{
transport.HierarchyNamespaceOptions = new HierarchyNamespaceOptions { HierarchyNamespace = connectionSettings.HierarchyNamespace };
}

transport.TransportTransactionMode = transport.GetSupportedTransactionModes().Contains(preferredTransactionMode) ? preferredTransactionMode : TransportTransactionMode.ReceiveOnly;

Expand All @@ -67,7 +71,8 @@ protected override void AddTransportForPrimaryCore(IServiceCollection services,
{
TopicToPublishTo = connectionSettings.TopicName,
TopicToSubscribeOn = connectionSettings.TopicName,
EventsToMigrateMap = [
EventsToMigrateMap =
[
"ServiceControl.Contracts.CustomCheckFailed",
"ServiceControl.Contracts.CustomCheckSucceeded",
"ServiceControl.Contracts.HeartbeatRestored",
Expand Down
6 changes: 5 additions & 1 deletion src/ServiceControl.Transports.ASBS/ConnectionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ public ConnectionSettings(AuthenticationMethod authenticationSettings,
string topicName = default,
bool useWebSockets = default,
bool enablePartitioning = default,
TimeSpan? queryDelayInterval = default)
TimeSpan? queryDelayInterval = default,
string hierarchyNamespace = default)
{
AuthenticationMethod = authenticationSettings;
TopicName = topicName;
UseWebSockets = useWebSockets;
EnablePartitioning = enablePartitioning;
QueryDelayInterval = queryDelayInterval;
HierarchyNamespace = hierarchyNamespace;
}

public AuthenticationMethod AuthenticationMethod { get; }
Expand All @@ -26,5 +28,7 @@ public ConnectionSettings(AuthenticationMethod authenticationSettings,
public bool UseWebSockets { get; }

public bool EnablePartitioning { get; }

public string HierarchyNamespace { get; }
}
}
23 changes: 16 additions & 7 deletions src/ServiceControl.Transports.ASBS/ConnectionStringParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public static ConnectionSettings Parse(string connectionString)
{
throw new Exception($"Can't parse {value} as a valid query delay interval.");
}

queryDelayInterval = TimeSpan.FromMilliseconds(delayInterval);
}

Expand Down Expand Up @@ -72,18 +73,25 @@ public static ConnectionSettings Parse(string connectionString)
}
}

string hierarchyNamespace = null;
if (builder.TryGetValue("HierarchyNamespace", out var hierarchyNamespaceString))
{
hierarchyNamespace = (string)hierarchyNamespaceString;
}

var shouldUseManagedIdentity = builder.TryGetValue("Authentication", out var authType) && (string)authType == "Managed Identity";

if (shouldUseManagedIdentity)
{
var fullyQualifiedNamespace = endpoint.ToString().TrimEnd('/').Replace("sb://", "");

return new ConnectionSettings(
new TokenCredentialAuthentication(fullyQualifiedNamespace, clientIdString),
topicNameString,
useWebSockets,
enablePartitioning,
queryDelayInterval);
new TokenCredentialAuthentication(fullyQualifiedNamespace, clientIdString),
topicNameString,
useWebSockets,
enablePartitioning,
queryDelayInterval,
hierarchyNamespace);
}

if (clientIdString != null)
Expand All @@ -96,7 +104,8 @@ public static ConnectionSettings Parse(string connectionString)
topicNameString,
useWebSockets,
enablePartitioning,
queryDelayInterval);
queryDelayInterval,
hierarchyNamespace);
}
}
}
}
2 changes: 1 addition & 1 deletion src/ServiceControl.Transports.ASBS/transport.manifest
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"DisplayName": "Azure Service Bus",
"AssemblyName": "ServiceControl.Transports.ASBS",
"TypeName": "ServiceControl.Transports.ASBS.ASBSTransportCustomization, ServiceControl.Transports.ASBS",
"SampleConnectionString": "Endpoint=sb://[namespace].servicebus.windows.net; SharedSecretIssuer=<owner>;SharedSecretValue=<someSecret>;QueueLengthQueryDelayInterval=<IntervalInMilliseconds(Default=500ms)>;TopicName=<TopicBundleName(Default=bundle-1)>;EnablePartitioning=<true|false(Default=false)>",
"SampleConnectionString": "Endpoint=sb://[namespace].servicebus.windows.net; SharedSecretIssuer=<owner>;SharedSecretValue=<someSecret>;QueueLengthQueryDelayInterval=<IntervalInMilliseconds(Default=500ms)>;TopicName=<TopicBundleName(Default=bundle-1)>;EnablePartitioning=<true|false(Default=false)>;HierarchyNamespace=<hierarchyNamespacePrefix>",
"AvailableInSCMU": true,
"Aliases": [
"ServiceControl.Transports.AzureServiceBus.AzureServiceBusTransport, ServiceControl.Transports.AzureServiceBus"
Expand Down
Loading