Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public static IEnumerable<TestCaseData> SupportedConnectionStrings
//Custom query delay interval
yield return new TestCaseData("Endpoint=sb://some.endpoint.name/;QueueLengthQueryDelayInterval=15000",
new ConnectionSettings(new SharedAccessSignatureAuthentication("Endpoint=sb://some.endpoint.name/;QueueLengthQueryDelayInterval=15000"), queryDelayInterval: TimeSpan.FromSeconds(15)));
//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));
}
}

Expand Down Expand Up @@ -61,13 +64,13 @@ public void VerifySupported(string connectionString, ConnectionSettings expected

Assert.AreEqual(JsonSerializer.Serialize(expected), JsonSerializer.Serialize(actual));

//needed since System..Text.Json doesn't handle polymorphic properties
//needed since System.Text.Json doesn't handle polymorphic properties
Assert.AreEqual(
JsonSerializer.Serialize(expected.AuthenticationMethod, expected.AuthenticationMethod.GetType()),
JsonSerializer.Serialize(actual.AuthenticationMethod, actual.AuthenticationMethod.GetType()));


//needed since System..Text.Json doesn't handle polymorphic properties
//needed since System.Text.Json doesn't handle polymorphic properties
if (expected.AuthenticationMethod is TokenCredentialAuthentication expectedAuthentication)
{
var actualAuthentication = actual.AuthenticationMethod as TokenCredentialAuthentication;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ void CustomizeEndpoint(
transport.UseWebSockets();
}

if (connectionSettings.EnablePartitioning)
{
transport.EnablePartitioning();
}

transport.ConfigureNameShorteners();
transport.Transactions(transportTransactionMode);

Expand Down
7 changes: 5 additions & 2 deletions src/ServiceControl.Transports.ASBS/ConnectionSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@

public class ConnectionSettings
{
public ConnectionSettings(
AuthenticationMethod authenticationSettings,
public ConnectionSettings(AuthenticationMethod authenticationSettings,
string topicName = default,
bool useWebSockets = default,
bool enablePartitioning = default,
TimeSpan? queryDelayInterval = default)
{
AuthenticationMethod = authenticationSettings;
TopicName = topicName;
UseWebSockets = useWebSockets;
EnablePartitioning = enablePartitioning;
QueryDelayInterval = queryDelayInterval;
}

Expand All @@ -23,5 +24,7 @@ public ConnectionSettings(
public string TopicName { get; }

public bool UseWebSockets { get; }

public bool EnablePartitioning { get; }
}
}
12 changes: 12 additions & 0 deletions src/ServiceControl.Transports.ASBS/ConnectionStringParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ public static ConnectionSettings Parse(string connectionString)
clientIdString = (string)clientId;
}

var enablePartitioning = false;
if (builder.TryGetValue("EnablePartitioning", out var enablePartitioningString))
{
if (!bool.TryParse((string)enablePartitioningString, out enablePartitioning))
{
throw new Exception(
$"Cannot enable partitioning, the specified value '{enablePartitioningString}' cannot be converted to a bool.");
}
}

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

if (shouldUseManagedIdentity)
Expand All @@ -72,6 +82,7 @@ public static ConnectionSettings Parse(string connectionString)
new TokenCredentialAuthentication(fullyQualifiedNamespace, clientIdString),
topicNameString,
useWebSockets,
enablePartitioning,
queryDelayInterval);
}

Expand All @@ -84,6 +95,7 @@ public static ConnectionSettings Parse(string connectionString)
new SharedAccessSignatureAuthentication(connectionString),
topicNameString,
useWebSockets,
enablePartitioning,
queryDelayInterval);
}
}
Expand Down
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 @@
"Name": "NetStandardAzureServiceBus",
"DisplayName": "Azure Service Bus",
"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)>",
"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)>",
"AvailableInSCMU": true,
"Aliases": [
"ServiceControl.Transports.AzureServiceBus.AzureServiceBusTransport, ServiceControl.Transports.AzureServiceBus"
Expand Down