greenie-msft / azd-infra-buildingblocks

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

For more details about this quickstart example please see the Pub-Sub Quickstart documentation.

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

Note: This example leverages the Dapr client SDK. If you are looking for the example using only HTTP requests click here.

This quickstart includes one publisher:

  • Python client message generator checkout

And one subscriber:

  • Python subscriber order-processor

Pre-requisites

For this example, you will need:

Run Python message subscriber with Dapr

  1. Install dependencies:
cd ./order-processor
pip3 install -r requirements.txt 
  1. Run the Python subscriber app with Dapr:
dapr run --app-id order-processor --components-path ../components/ --app-port 5001 -- python3 app.py

Run Python message publisher with Dapr

  1. Install dependencies:
cd ./checkout
pip3 install -r requirements.txt 
  1. Run the Python publisher app with Dapr:
dapr run --app-id checkout --components-path ../components/ -- python3 app.py
dapr stop --app-id checkout
dapr stop --app-id order-processor

Deploy to Azure (Azure Container Apps and Azure Service Bus)

  1. Deploy to Azure for dev-test

NOTE: make sure you have Azure Dev CLI pre-reqs here

azd up

About


Languages

Language:Bicep 94.2%Language:Dockerfile 3.4%Language:Python 2.2%Language:Makefile 0.2%