Skip to content

Commit 8e74359

Browse files
Update NServiceBus Step By Step tutorial to use Microsoft.Extensions.Logging (#6861)
* Update NServiceBus Step By Step tutorial to use Microsoft Extensions Logging * Update step by step tutorial, step 1 client ui project * Update the step-by-step tutorials * Update ClientUI.csproj * NSB step-by-step tutorial clean up * Updates to Snippet and tutorial for Lesson 1 * updates to lesson 1 snippets * changes to lesson 2 snippets * Lesson 3 snippets update * Updated snippets for lesson 4 * Added missing snippet * Delete unused snippet * Minor updates to step 1 & 2 * fixed issue with csproj * Updates to version on step 3 * Update to the step 2 tutorial * Updates to steps 4 & 5 * step 1 tweaks * step 2 * step 3 * step 4 * step 5 * Update tutorial.md * Update tutorial.md * Update tutorial.md * Update tutorial.md --------- Co-authored-by: Tomek Masternak <[email protected]>
1 parent 4b47e6e commit 8e74359

File tree

93 files changed

+1145
-1038
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1145
-1038
lines changed

tutorials/nservicebus-step-by-step/1-getting-started/Snippets/Core_8/Core_8.csproj

-9
This file was deleted.

tutorials/nservicebus-step-by-step/1-getting-started/Snippets/Core_8/Lesson1.cs

-65
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net8.0</TargetFramework>
4+
<LangVersion>12.0</LangVersion>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageReference Include="NServiceBus" Version="9.*" />
8+
<PackageReference Include="NServiceBus.Extensions.Hosting" Version="3.*" />
9+
</ItemGroup>
10+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Microsoft.Extensions.Hosting;
4+
using NServiceBus;
5+
6+
namespace Core_9;
7+
#pragma warning disable 1998
8+
9+
#region EmptyProgram
10+
class Program
11+
{
12+
static async Task Main(string[] args)
13+
{
14+
15+
}
16+
}
17+
#endregion
18+
19+
class StepByStep
20+
{
21+
#region Main
22+
23+
static async Task Main(string[] args)
24+
{
25+
var builder = Host.CreateApplicationBuilder(args);
26+
27+
var endpointConfiguration = new EndpointConfiguration("ClientUI");
28+
29+
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
30+
31+
var routing = endpointConfiguration.UseTransport(new LearningTransport());
32+
33+
}
34+
#endregion
35+
36+
static async Task Steps(string[] args)
37+
{
38+
#region ConsoleTitle
39+
Console.Title = "ClientUI";
40+
#endregion
41+
42+
#region Setup
43+
var builder = Host.CreateApplicationBuilder(args);
44+
#endregion
45+
46+
#region EndpointName
47+
var endpointConfiguration = new EndpointConfiguration("ClientUI");
48+
49+
// Choose JSON to serialize and deserialize messages
50+
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
51+
#endregion
52+
53+
#region LearningTransport
54+
var transport = endpointConfiguration.UseTransport<LearningTransport>();
55+
#endregion
56+
57+
#region Startup
58+
builder.UseNServiceBus(endpointConfiguration);
59+
60+
await builder.Build().RunAsync();
61+
#endregion
62+
}
63+
}
64+
65+
#pragma warning restore 1998

tutorials/nservicebus-step-by-step/1-getting-started/Snippets/Snippets.sln

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29728.190
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.11.35303.130
54
MinimumVisualStudioVersion = 15.0.26730.12
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Core_8", "Core_8\Core_8.csproj", "{10CE989A-8E4F-400C-8BBD-3935B9FEE695}"
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Core_9", "Core_9\Core_9.csproj", "{10CE989A-8E4F-400C-8BBD-3935B9FEE695}"
76
EndProject
87
Global
98
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
<Project Sdk="Microsoft.NET.Sdk">
1+
<Project Sdk="Microsoft.NET.Sdk">
22
<PropertyGroup>
33
<TargetFramework>net8.0</TargetFramework>
44
<OutputType>Exe</OutputType>
55
<LangVersion>12.0</LangVersion>
66
</PropertyGroup>
77
<ItemGroup>
88
<PackageReference Include="NServiceBus" Version="9.*" />
9+
<PackageReference Include="NServiceBus.Extensions.Hosting" Version="3.*" />
910
</ItemGroup>
1011
</Project>
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
1-
using NServiceBus;
2-
using System;
1+
using Microsoft.Extensions.DependencyInjection;
32
using System.Threading.Tasks;
3+
using Microsoft.Extensions.Hosting;
4+
using NServiceBus;
5+
using System;
46

5-
namespace ClientUI
7+
namespace ClientUI;
8+
class Program
69
{
7-
class Program
10+
static async Task Main(string[] args)
811
{
9-
static async Task Main()
10-
{
11-
Console.Title = "ClientUI";
12+
Console.Title = "ClientUI";
1213

13-
var endpointConfiguration = new EndpointConfiguration("ClientUI");
14+
var builder = Host.CreateApplicationBuilder(args);
1415

15-
var transport = endpointConfiguration.UseTransport<LearningTransport>();
16+
var endpointConfiguration = new EndpointConfiguration("ClientUI");
1617

17-
// Choose JSON to serialize and deserialize messages
18-
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
18+
endpointConfiguration.UseSerialization<SystemJsonSerializer>();
1919

20-
var endpointInstance = await Endpoint.Start(endpointConfiguration);
20+
var transport = endpointConfiguration.UseTransport(new LearningTransport());
2121

22-
Console.WriteLine("Press Enter to exit...");
23-
Console.ReadLine();
22+
builder.UseNServiceBus(endpointConfiguration);
2423

25-
await endpointInstance.Stop();
26-
}
24+
await builder.Build().RunAsync();
2725
}
2826
}
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,24 @@
1-
21
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 16
4-
VisualStudioVersion = 16.0.29728.190
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.11.35303.130
54
MinimumVisualStudioVersion = 15.0.26730.12
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ClientUI", "ClientUI\ClientUI.csproj", "{D4DCF868-A625-4B0B-BB20-C150553A6548}"
5+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClientUI", "ClientUI\ClientUI.csproj", "{D4DCF868-A625-4B0B-BB20-C150553A6548}"
76
EndProject
87
Global
98
GlobalSection(SolutionConfigurationPlatforms) = preSolution
109
Debug|Any CPU = Debug|Any CPU
10+
Release|Any CPU = Release|Any CPU
1111
EndGlobalSection
1212
GlobalSection(ProjectConfigurationPlatforms) = postSolution
1313
{D4DCF868-A625-4B0B-BB20-C150553A6548}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
1414
{D4DCF868-A625-4B0B-BB20-C150553A6548}.Debug|Any CPU.Build.0 = Debug|Any CPU
15+
{D4DCF868-A625-4B0B-BB20-C150553A6548}.Release|Any CPU.ActiveCfg = Release|Any CPU
16+
{D4DCF868-A625-4B0B-BB20-C150553A6548}.Release|Any CPU.Build.0 = Release|Any CPU
1517
EndGlobalSection
1618
GlobalSection(SolutionProperties) = preSolution
1719
HideSolutionNode = FALSE
1820
EndGlobalSection
21+
GlobalSection(ExtensibilityGlobals) = postSolution
22+
SolutionGuid = {3C7A7BB7-52B2-4A1E-971C-EA47CC1833E2}
23+
EndGlobalSection
1924
EndGlobal

tutorials/nservicebus-step-by-step/1-getting-started/tutorial.md

+7-1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ snippet: ConsoleTitle
6969

7070
When running multiple console apps in the same solution, giving each one a name makes them easier to identify. This console app's title is `ClientUI`. In later lessons, we'll expand this solution to host multiple applications.
7171

72+
#### Setup
73+
74+
snippet: Setup
75+
76+
The host is typically configured, built, and run by code in the `Program` class. The `CreateApplicationBuilder` method creates and configures a builder object.
77+
7278
#### EndpointConfiguration
7379

7480
snippet: EndpointName
@@ -86,7 +92,7 @@ Capturing the `transport` settings in a variable as shown will make things easie
8692

8793
### Starting up
8894

89-
At the end of the `Main` method, after the configuration code, add the following lines which will start the endpoint and keep it running until you press the <kbd>Enter</kbd> key to shut it down.
95+
At the end of the `Main` method, after the configuration code, add the following lines which will start the endpoint and keep it running until you press the <kbd>Ctrl+C</kbd> to shut it down.
9096

9197
snippet: Startup
9298

tutorials/nservicebus-step-by-step/2-sending-a-command/Snippets/Core_8/Command.cs

-14
This file was deleted.

tutorials/nservicebus-step-by-step/2-sending-a-command/Snippets/Core_8/ComplexCommand.cs

-22
This file was deleted.

tutorials/nservicebus-step-by-step/2-sending-a-command/Snippets/Core_8/Core_8.csproj

-9
This file was deleted.

tutorials/nservicebus-step-by-step/2-sending-a-command/Snippets/Core_8/EmptyHandler.cs

-17
This file was deleted.

tutorials/nservicebus-step-by-step/2-sending-a-command/Snippets/Core_8/EmptyHandlerAsync.cs

-18
This file was deleted.

0 commit comments

Comments
 (0)