Skip to content

Commit 68aa4a1

Browse files
committed
Add routing diagnostics to diagnostics doc page Closes GH-324
1 parent af7610f commit 68aa4a1

File tree

6 files changed

+58
-8
lines changed

6 files changed

+58
-8
lines changed

docs/guide/diagnostics.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,3 +150,36 @@ public static void assert_configuration_is_valid(IHost host)
150150
Note that this method will attempt to generate and compile the source code for each message type and use [Lamar's own
151151
diagnostics](https://jasperfx.github.io/lamar/guide/ioc/diagnostics/) as well.
152152

153+
## Troubleshooting Message Routing
154+
155+
Among other information, you can find a preview of how Wolverine will route known message types through the command line
156+
with:
157+
158+
```bash
159+
dotnet run -- describe
160+
```
161+
162+
Part of this output is a table of the known message types and the routed destination of any subscriptions. You can enhance
163+
this diagnostic by helping Wolverine to [discover message types](/guide/messages#message-discovery) in your system.
164+
165+
And lastly, there's a programmatic way to "preview" the Wolverine message routing at runtime that might
166+
be helpful:
167+
168+
<!-- snippet: sample_using_preview_subscriptions -->
169+
<a id='snippet-sample_using_preview_subscriptions'></a>
170+
```cs
171+
public static void using_preview_subscriptions(IMessageBus bus)
172+
{
173+
// Preview where Wolverine is wanting to send a message
174+
var outgoing = bus.PreviewSubscriptions(new BlueMessage());
175+
foreach (var envelope in outgoing)
176+
{
177+
// The URI value here will identify the endpoint where the message is
178+
// going to be sent (Rabbit MQ exchange, Azure Service Bus topic, Kafka topic, local queue, etc.)
179+
Debug.WriteLine(envelope.Destination);
180+
}
181+
}
182+
```
183+
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Testing/CoreTests/Runtime/Routing/routing_precedence.cs#L76-L90' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_using_preview_subscriptions' title='Start of snippet'>anchor</a></sup>
184+
<!-- endSnippet -->
185+

docs/guide/durability/efcore.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ builder.Host.UseWolverine(opts =>
3131
opts.Policies.UseDurableLocalQueues();
3232
});
3333
```
34-
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/Program.cs#L35-L52' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_registering_efcore_middleware' title='Start of snippet'>anchor</a></sup>
34+
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/Program.cs#L36-L53' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_registering_efcore_middleware' title='Start of snippet'>anchor</a></sup>
3535
<!-- endSnippet -->
3636

3737
::: tip
@@ -124,7 +124,7 @@ this syntax for the service registration:
124124
builder.Services.AddDbContextWithWolverineIntegration<ItemsDbContext>(
125125
x => x.UseSqlServer(connectionString), "wolverine");
126126
```
127-
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/Program.cs#L18-L25' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_optimized_efcore_registration' title='Start of snippet'>anchor</a></sup>
127+
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/Program.cs#L19-L26' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_optimized_efcore_registration' title='Start of snippet'>anchor</a></sup>
128128
<!-- endSnippet -->
129129

130130
That registration will:
@@ -219,7 +219,7 @@ public async Task Post(
219219
await outbox.SaveChangesAndFlushMessagesAsync();
220220
}
221221
```
222-
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/CreateItemController.cs#L8-L38' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_using_dbcontext_outbox_1' title='Start of snippet'>anchor</a></sup>
222+
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/CreateItemController.cs#L10-L40' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_using_dbcontext_outbox_1' title='Start of snippet'>anchor</a></sup>
223223
<!-- endSnippet -->
224224

225225
Or use the `IDbContextOutbox` as shown below, but in this case you will need to explicitly call `Enroll()` on
@@ -261,7 +261,7 @@ public async Task Post3(
261261
await outbox.SaveChangesAndFlushMessagesAsync();
262262
}
263263
```
264-
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/CreateItemController.cs#L41-L76' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_using_dbcontext_outbox_2' title='Start of snippet'>anchor</a></sup>
264+
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/CreateItemController.cs#L43-L78' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_using_dbcontext_outbox_2' title='Start of snippet'>anchor</a></sup>
265265
<!-- endSnippet -->
266266

267267
## As Saga Storage

docs/guide/durability/managing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ To have any missing database schema objects built as needed on application start
7575
// This is rebuilding the persistent storage database schema on startup
7676
builder.Host.UseResourceSetupOnStartup();
7777
```
78-
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/Program.cs#L54-L59' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_resource_setup_on_startup' title='Start of snippet'>anchor</a></sup>
78+
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/Program.cs#L55-L60' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_resource_setup_on_startup' title='Start of snippet'>anchor</a></sup>
7979
<!-- endSnippet -->
8080

8181
## Command Line Management
@@ -89,7 +89,7 @@ shown in this last line of a .NET 6/7 `Program` code file:
8989
// Opt into using Oakton for command parsing
9090
await app.RunOaktonCommands(args);
9191
```
92-
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/Program.cs#L80-L85' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_using_oakton_for_command_line_parsing' title='Start of snippet'>anchor</a></sup>
92+
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/Program.cs#L83-L88' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_using_oakton_for_command_line_parsing' title='Start of snippet'>anchor</a></sup>
9393
<!-- endSnippet -->
9494

9595
And you're using the message persistence from either the `WolverineFx.SqlServer` or `WolverineFx.Postgresql`

docs/guide/durability/sqlserver.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ builder.Host.UseWolverine(opts =>
3030
opts.Policies.UseDurableLocalQueues();
3131
});
3232
```
33-
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/Program.cs#L35-L52' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_registering_efcore_middleware' title='Start of snippet'>anchor</a></sup>
33+
<sup><a href='https://github.com/JasperFx/wolverine/blob/main/src/Samples/EFCoreSample/ItemService/Program.cs#L36-L53' title='Snippet source file'>snippet source</a> | <a href='#snippet-sample_registering_efcore_middleware' title='Start of snippet'>anchor</a></sup>
3434
<!-- endSnippet -->
3535

3636
## Sql Server Messaging Transport

docs/tutorials/best-practices.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,4 +224,4 @@ has quite a bit of features specifically to support a "Vertical Slice Architectu
224224
to utilize Wolverine to create a maintainable codebase with much less complexity than the state of the art Clean/Onion
225225
layered approach.
226226

227-
See [Low Ceremony Vertical Slice Architecture with Wolverine](https://jeremydmiller.com/2023/07/10/low-ceremony-vertical-slice-architecture-with-wolverine/)
227+
See [Low Ceremony Vertical Slice Architecture with Wolverine](https://jeremydmiller.com/2023/07/10/low-ceremony-vertical-slice-architecture-with-wolverine/)

src/Testing/CoreTests/Runtime/Routing/routing_precedence.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.CodeDom.Compiler;
33
using System.Collections.Generic;
4+
using System.Diagnostics;
45
using System.Linq;
56
using System.Threading.Tasks;
67
using Microsoft.Extensions.DependencyInjection;
@@ -71,6 +72,22 @@ public async Task explicit_routing_to_local_wins()
7172
bus.PreviewSubscriptions(new BlueMessage())
7273
.Single().Destination.ShouldBe(new Uri("local://purple"));
7374
}
75+
76+
#region sample_using_preview_subscriptions
77+
78+
public static void using_preview_subscriptions(IMessageBus bus)
79+
{
80+
// Preview where Wolverine is wanting to send a message
81+
var outgoing = bus.PreviewSubscriptions(new BlueMessage());
82+
foreach (var envelope in outgoing)
83+
{
84+
// The URI value here will identify the endpoint where the message is
85+
// going to be sent (Rabbit MQ exchange, Azure Service Bus topic, Kafka topic, local queue, etc.)
86+
Debug.WriteLine(envelope.Destination);
87+
}
88+
}
89+
90+
#endregion
7491

7592
[Fact]
7693
public async Task explicit_routing_to_elsewhere_wins()

0 commit comments

Comments
 (0)