quickstarts/pub_sub/csharp/http
Phil Ngan 741a8f7ad9 Converted all projects to net8.0
Exception is batch because Swashbuckle does not support net8

Signed-off-by: Phil Ngan <phillip.ngan@gmail.com>
2024-02-18 16:12:57 +13:00
..
checkout Converted all projects to net8.0 2024-02-18 16:12:57 +13:00
order-processor Converted all projects to net8.0 2024-02-18 16:12:57 +13:00
README.md Patching tests to pass (C# timing, Python uvicorn) (#933) 2023-09-22 12:28:15 -07:00
checkout.sln create http and sdk directories for each language 2022-02-14 15:57:15 -08:00
dapr.yaml Updating Readme's to default to `dapr run -f .` (#874) 2023-09-22 10:02:07 -07:00
makefile Removed docker image prefix addition step 2022-07-25 12:28:57 -07:00

README.md

Dapr pub/sub (HTTP Client)

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 to understand when this pattern might be a good choice for your software architecture.

Visit this link for more information about Dapr and Pub-Sub.

Note: This example leverages HTTPClient only. If you are looking for the example using the Dapr Client SDK (recommended) click here.

This quickstart includes one publisher:

  • Dotnet client message generator checkout

And one subscriber:

  • Dotnet subscriber order-processor

Run all apps with multi-app run template file:

This section shows how to run both applications at once using multi-app run template files with dapr run -f .. This enables to you test the interactions between multiple applications.

  1. Open a new terminal window and run order-processor and checkout using the multi app run template defined in dapr.yaml:
dapr run -f .

The terminal console output should look similar to this:

== APP - checkout-http == Published data: Order { OrderId = 1 }
== APP - order-processor-http == Subscriber received : 1
== APP - checkout-http == Published data: Order { OrderId = 2 }
== APP - order-processor-http == Subscriber received : 2
== APP - checkout-http == Published data: Order { OrderId = 3 }
== APP - order-processor-http == Subscriber received : 3
== APP - checkout-http == Published data: Order { OrderId = 4 }
== APP - order-processor-http == Subscriber received : 4
== APP - checkout-http == Published data: Order { OrderId = 5 }
== APP - order-processor-http == Subscriber received : 5
== APP - checkout-http == Published data: Order { OrderId = 6 }
== APP - order-processor-http == Subscriber received : 6
== APP - checkout-http == Published data: Order { OrderId = 7 }
== APP - order-processor-http == Subscriber received : 7
== APP - checkout-http == Published data: Order { OrderId = 8 }
== APP - order-processor-http == Subscriber received : 8
== APP - checkout-http == Published data: Order { OrderId = 9 }
== APP - order-processor-http == Subscriber received : 9
== APP - checkout-http == Published data: Order { OrderId = 10 }
== APP - order-processor-http == Subscriber received : 10
  1. Stop and clean up application processes
dapr stop -f .

Run a single app at a time with Dapr (Optional)

An alternative to running all or multiple applications at once is to run single apps one-at-a-time using multiple dapr run .. -- dotnet run commands. This next section covers how to do this.

Run Dotnet message subscriber with Dapr

  1. Run the Dotnet subscriber app with Dapr:
cd ./order-processor
dapr run --app-id order-processor-http --resources-path ../../../components/ --app-port 7005 -- dotnet run

Run Dotnet message publisher with Dapr

  1. Run the Dotnet publisher app with Dapr:
cd ./checkout
dapr run --app-id checkout-http --resources-path ../../../components/ -- dotnet run
  1. Stop and clean up application processes
dapr stop --app-id order-processor-http
dapr stop --app-id checkout-http