Adding Dotnet readme, and fixed bugs on .NET 6 routes

Signed-off-by: Paul Yuknewicz <paulyuk@microsoft.com>
This commit is contained in:
Paul Yuknewicz 2022-01-31 10:13:26 -08:00 committed by Artur Souza
parent 6b788e60fd
commit c9e388c054
3 changed files with 105 additions and 5 deletions

99
pub_sub/csharp/README.md Normal file
View File

@ -0,0 +1,99 @@
# Dapr pub/sub
In this quickstart, you'll create a publisher microservice and a subscriber microservice to demonstrate how Dapr enables a publish-subcribe pattern. The publisher will generate messages of a specific topic, while subscribers will listen for messages of specific topics. See [Why Pub-Sub](#why-pub-sub) to understand when this pattern might be a good choice for your software architecture.
Visit [this](https://docs.dapr.io/developing-applications/building-blocks/pubsub/) link for more information about Dapr and Pub-Sub.
This quickstart includes one publisher:
- Dotnet client message generator `checkout`
And one subscriber:
- Dotnet subscriber `order-processor`
### Run Dotnet message publisher with Dapr
1. Open a new terminal window and navigate to `checkout` directory:
```bash
cd checkout
```
2. Install dependencies:
<!-- STEP
name: Install Dotnet dependencies
working_dir: ./checkout
-->
```bash
dotnet restore
dotnet build
```
3. Run the Dotnet publisher app with Dapr:
<!-- STEP
name: Run Dotnet publisher
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- '== APP == Received message "Message on A" on topic "A"'
- '== APP == Received message "Message on C" on topic "C"'
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
working_dir: ./checkout
background: true
sleep: 10
-->
```bash
dapr run --app-id checkout --components-path ../../components/ -- dotnet run
```
<!-- END_STEP -->
### Run Dotnet message subscriber with Dapr
1. Open a new terminal window and navigate to `checkout` directory:
```bash
cd order-processor
```
2. Install dependencies:
<!-- STEP
name: Install Dotnet dependencies
working_dir: ./order-processor
-->
```bash
dotnet restore
dotnet build
```
3. Run the Dotnet subscriber app with Dapr:
<!-- STEP
name: Run Dotnet subscriber
expected_stdout_lines:
- "You're up and running! Both Dapr and your app logs will appear here."
- '== APP == Received message "Message on A" on topic "A"'
- '== APP == Received message "Message on C" on topic "C"'
- "Exited Dapr successfully"
- "Exited App successfully"
expected_stderr_lines:
output_match_mode: substring
working_dir: ./order-processor
background: true
sleep: 10
-->
```bash
dapr run --app-id order-processor --components-path ../../components/ --app-port 5001 -- dotnet run
```
<!-- END_STEP -->

View File

@ -20,9 +20,9 @@ app.MapGet("/dapr/subscribe", () => {
return subscriptions;
});
app.MapPost("/orders", async (Order order) => {
app.MapPost("/orders", (Order order) => {
Console.WriteLine("Subscriber received : " + order.ToString());
return new HttpResponseMessage(HttpStatusCode.OK);
return Results.Ok(order.ToString());
});
// [Topic("order_pub_sub", "orders")]

View File

@ -2,12 +2,13 @@
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<Nullable>disable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
<PackageReference Include="Dapr.AspNetCore" Version="1.4.0" />
</ItemGroup>