-
Notifications
You must be signed in to change notification settings - Fork 301
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NServiceBus step by step tutorial cleanup #6903
Open
andreasohlund
wants to merge
7
commits into
master
Choose a base branch
from
nsb-tutorial-cleanup
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
db1f094
Switch to use top level statements
andreasohlund 3ba69a2
Cleanup lesson 1 solution
andreasohlund c289873
Cleanup part 2
andreasohlund ecc9740
Cleanup part 3
andreasohlund 14c22aa
Cleanup part 4
andreasohlund 17f1665
ASQ has native pub sub
andreasohlund c315fd8
Cleanup part 5
andreasohlund File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 8 additions & 17 deletions
25
tutorials/nservicebus-step-by-step/1-getting-started/Solution/ClientUI/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,17 @@ | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Hosting; | ||
using Microsoft.Extensions.Hosting; | ||
using NServiceBus; | ||
using System; | ||
|
||
namespace ClientUI; | ||
class Program | ||
{ | ||
static async Task Main(string[] args) | ||
{ | ||
Console.Title = "ClientUI"; | ||
Console.Title = "ClientUI"; | ||
|
||
var builder = Host.CreateApplicationBuilder(args); | ||
var builder = Host.CreateApplicationBuilder(args); | ||
|
||
var endpointConfiguration = new EndpointConfiguration("ClientUI"); | ||
var endpointConfiguration = new EndpointConfiguration("ClientUI"); | ||
|
||
endpointConfiguration.UseSerialization<SystemJsonSerializer>(); | ||
endpointConfiguration.UseSerialization<SystemJsonSerializer>(); | ||
|
||
var transport = endpointConfiguration.UseTransport(new LearningTransport()); | ||
var transport = endpointConfiguration.UseTransport(new LearningTransport()); | ||
|
||
builder.UseNServiceBus(endpointConfiguration); | ||
builder.UseNServiceBus(endpointConfiguration); | ||
|
||
await builder.Build().RunAsync(); | ||
} | ||
} | ||
await builder.Build().RunAsync(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,22 +43,17 @@ static async Task Steps(string[] args) | |
await builder.Build().RunAsync(); | ||
#endregion | ||
} | ||
|
||
static Task RunLoop(IEndpointInstance endpoint) | ||
{ | ||
return Task.CompletedTask; | ||
} | ||
} | ||
|
||
#region InputLoopService | ||
|
||
public class InputLoopService(IMessageSession messageSession, ILogger<InputLoopService> logger) : BackgroundService | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we are interacting with the console anyway I figured that it would be more consistent to continue to use Console.WriteLine rather than mixing with logging |
||
public class InputLoopService(IMessageSession messageSession) : BackgroundService | ||
{ | ||
protected override async Task ExecuteAsync(CancellationToken stoppingToken) | ||
{ | ||
while (true) | ||
{ | ||
logger.LogInformation("Press 'P' to place an order, or 'Q' to quit."); | ||
Console.WriteLine("Press 'P' to place an order, or 'Q' to quit."); | ||
var key = Console.ReadKey(); | ||
Console.WriteLine(); | ||
|
||
|
@@ -72,16 +67,16 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) | |
}; | ||
|
||
// Send the command | ||
logger.LogInformation("Sending PlaceOrder command, OrderId = {OrderId}", command.OrderId); | ||
await messageSession.SendLocal(command); | ||
Console.WriteLine($"Sending PlaceOrder command, OrderId = {command.OrderId}"); | ||
await messageSession.SendLocal(command, stoppingToken); | ||
|
||
break; | ||
|
||
case ConsoleKey.Q: | ||
return; | ||
|
||
default: | ||
logger.LogInformation("Unknown input. Please try again."); | ||
Console.WriteLine("Unknown input. Please try again."); | ||
break; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 9 additions & 17 deletions
26
tutorials/nservicebus-step-by-step/2-sending-a-command/Solution/ClientUI/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,21 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using ClientUI; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Hosting; | ||
using NServiceBus; | ||
|
||
namespace ClientUI; | ||
Console.Title = "ClientUI"; | ||
|
||
class Program | ||
{ | ||
static async Task Main(string[] args) | ||
{ | ||
Console.Title = "ClientUI"; | ||
var builder = Host.CreateApplicationBuilder(args); | ||
|
||
var builder = Host.CreateApplicationBuilder(args); | ||
var endpointConfiguration = new EndpointConfiguration("ClientUI"); | ||
|
||
var endpointConfiguration = new EndpointConfiguration("ClientUI"); | ||
endpointConfiguration.UseSerialization<SystemJsonSerializer>(); | ||
|
||
endpointConfiguration.UseSerialization<SystemJsonSerializer>(); | ||
endpointConfiguration.UseTransport(new LearningTransport()); | ||
|
||
endpointConfiguration.UseTransport(new LearningTransport()); | ||
builder.UseNServiceBus(endpointConfiguration); | ||
|
||
builder.UseNServiceBus(endpointConfiguration); | ||
builder.Services.AddHostedService<InputLoopService>(); | ||
|
||
builder.Services.AddHostedService<InputLoopService>(); | ||
|
||
await builder.Build().RunAsync(); | ||
} | ||
} | ||
await builder.Build().RunAsync(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm unsure if this note makes sense since this is targeted at users learning to use our latest version.