Skip to content

Commit 533539f

Browse files
Use partials in ASB tool docs (#6995)
* Use partials in asbs tool docs * Topology selection * More partials * Latest alpha * Fix snippet * Split up shortening * Overlap * Further split the topology * Inline hierarchy * Hack it for now --------- Co-authored-by: Daniel Marbach <[email protected]>
1 parent 051adcd commit 533539f

22 files changed

+771
-268
lines changed

Snippets/ASBS/ASBS.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
23
# Visual Studio Version 17
34
VisualStudioVersion = 17.4.33122.133
45
MinimumVisualStudioVersion = 15.0.26730.12
@@ -14,6 +15,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ASBS_3.2", "ASBS_3.2\ASBS_3
1415
EndProject
1516
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASBS_4", "ASBS_4\ASBS_4.csproj", "{87EF58A5-99B5-4D4F-AB4A-5B10F7806499}"
1617
EndProject
18+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ASBS_5", "ASBS_5\ASBS_5.csproj", "{6CA4021C-42C5-45F3-9AFA-50A6DBA42BAE}"
19+
EndProject
1720
Global
1821
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1922
Debug|Any CPU = Debug|Any CPU
@@ -44,6 +47,10 @@ Global
4447
{87EF58A5-99B5-4D4F-AB4A-5B10F7806499}.Debug|Any CPU.Build.0 = Debug|Any CPU
4548
{87EF58A5-99B5-4D4F-AB4A-5B10F7806499}.Release|Any CPU.ActiveCfg = Release|Any CPU
4649
{87EF58A5-99B5-4D4F-AB4A-5B10F7806499}.Release|Any CPU.Build.0 = Release|Any CPU
50+
{6CA4021C-42C5-45F3-9AFA-50A6DBA42BAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51+
{6CA4021C-42C5-45F3-9AFA-50A6DBA42BAE}.Debug|Any CPU.Build.0 = Debug|Any CPU
52+
{6CA4021C-42C5-45F3-9AFA-50A6DBA42BAE}.Release|Any CPU.ActiveCfg = Release|Any CPU
53+
{6CA4021C-42C5-45F3-9AFA-50A6DBA42BAE}.Release|Any CPU.Build.0 = Release|Any CPU
4754
EndGlobalSection
4855
GlobalSection(SolutionProperties) = preSolution
4956
HideSolutionNode = FALSE

Snippets/ASBS/ASBS_5/ASBS_5.csproj

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net9.0</TargetFramework>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<PackageReference Include="Azure.Identity" Version="1.12.0" />
7+
<PackageReference Include="NServiceBus.Transport.AzureServiceBus" Version="5.0.0-alpha.4" />
8+
</ItemGroup>
9+
</Project>
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
using Azure.Messaging.ServiceBus;
2+
using NServiceBus;
3+
using NServiceBus.Pipeline;
4+
using System;
5+
using System.Threading.Tasks;
6+
7+
public class AccessToNativeMessage
8+
{
9+
#region access-native-incoming-message
10+
11+
class DoNotAttemptMessageProcessingIfMessageIsNotLocked : Behavior<ITransportReceiveContext>
12+
{
13+
public override Task Invoke(ITransportReceiveContext context, Func<Task> next)
14+
{
15+
var lockedUntilUtc = context.Extensions.Get<ServiceBusReceivedMessage>().LockedUntil;
16+
17+
if (lockedUntilUtc <= DateTime.UtcNow)
18+
{
19+
return next();
20+
}
21+
22+
throw new Exception($"Message lock lost for MessageId {context.Message.MessageId} and it cannot be processed.");
23+
}
24+
}
25+
26+
#endregion
27+
28+
class AccessOutgoingNativeMessage
29+
{
30+
async Task AccessNativeOutgoingMessageFromHandler(IMessageHandlerContext context)
31+
{
32+
#region access-native-outgoing-message
33+
// send a command
34+
var sendOptions = new SendOptions();
35+
sendOptions.CustomizeNativeMessage(m => m.Subject = "custom-label");
36+
await context.Send(new MyCommand(), sendOptions);
37+
38+
// publish an event
39+
var publishOptions = new PublishOptions();
40+
publishOptions.CustomizeNativeMessage(m => m.Subject = "custom-label");
41+
await context.Publish(new MyEvent(), publishOptions);
42+
#endregion
43+
}
44+
45+
class MyCommand { }
46+
class MyEvent { }
47+
}
48+
}

Snippets/ASBS/ASBS_5/Usage.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
using System;
2+
using System.Security.Cryptography;
3+
using System.Text;
4+
5+
using Azure.Identity;
6+
7+
using NServiceBus;
8+
9+
class Usage
10+
{
11+
Usage(EndpointConfiguration endpointConfiguration)
12+
{
13+
#region azure-service-bus-for-dotnet-standard
14+
15+
var transport = new AzureServiceBusTransport("Endpoint=sb://[NAMESPACE].servicebus.windows.net/;SharedAccessKeyName=[KEYNAME];SharedAccessKey=[KEY]", TopicTopology.Default);
16+
endpointConfiguration.UseTransport(transport);
17+
18+
#endregion
19+
20+
#region token-credentials
21+
22+
var transportWithTokenCredentials = new AzureServiceBusTransport("[NAMESPACE].servicebus.windows.net", new DefaultAzureCredential(), TopicTopology.Default);
23+
endpointConfiguration.UseTransport(transportWithTokenCredentials);
24+
25+
#endregion
26+
27+
#region custom-prefetch-multiplier
28+
29+
transport.PrefetchMultiplier = 3;
30+
31+
#endregion
32+
33+
#region custom-prefetch-count
34+
35+
transport.PrefetchCount = 100;
36+
37+
#endregion
38+
39+
#region custom-auto-lock-renewal
40+
41+
transport.MaxAutoLockRenewalDuration = TimeSpan.FromMinutes(10);
42+
43+
#endregion
44+
45+
#pragma warning disable CS0618 // Type or member is obsolete
46+
#region asb-sanitization-compatibility
47+
48+
var migrationTopology = TopicTopology.MigrateFromSingleDefaultTopic();
49+
migrationTopology.OverrideSubscriptionNameFor("QueueName", "ShortenedSubscriptionName");
50+
51+
migrationTopology.EventToMigrate<MyEvent>("ShortenedRuleName");
52+
53+
#endregion
54+
#pragma warning restore CS0618 // Type or member is obsolete
55+
}
56+
57+
class MyEvent;
58+
}

Snippets/ASBS/ASBS_5/prerelease.txt

Whitespace-only changes.

transports/azure-service-bus/compatibility.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,4 @@ The Azure Service Bus transport doesn't support namespace aliases.
3535

3636
If the legacy transport [sanitizes](/transports/azure-service-bus/configuration.md#entity-creation) entity names, the sanitization logic must be updated to be compatible with the new transport.
3737

38-
For example, for the `ValidateAndHashIfNeeded` strategy, the sanitization functions must include the strategy logic to preserve the same entity names.
39-
40-
snippet: asb-sanitization-compatibility
38+
partial: Shortening
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
For example, for the `ValidateAndHashIfNeeded` strategy, the sanitization functions must include the strategy logic to preserve the same entity names.
2+
3+
snippet: asb-sanitization-compatibility
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
For example, for the `ValidateAndHashIfNeeded` strategy, the sanitization functions must include the strategy logic to preserve the same entity names.
2+
3+
For queue names or event names that crossed the threshold of 50 characters it is necessary to precalculate the MD5 hash and store that as the subscription or rule name. Alternatively simply configure the subscription or rule name already used in production as a hardcoded value.
4+
5+
snippet: asb-sanitization-compatibility

transports/azure-service-bus/configuration_entity-topology_asbs_[3,).partial.md renamed to transports/azure-service-bus/configuration_entity-topology_asbs_[3,5).partial.md

File renamed without changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
### Topology

0 commit comments

Comments
 (0)