Skip to content

A complete microservice application featuring Dapr Pub-Sub, deployed to Azure Container Apps and Azure Service Bus Topics with dead-lettering support.

Notifications You must be signed in to change notification settings

Azure-Samples/pubsub-dapr-nodejs-servicebus

Repository files navigation

Microservice communication using pubsub (async)

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:

  • Node client message generator checkout

And one subscriber:

  • Node subscriber order-processor

Pre-requisites

For this example, you will need:

Run Node message subscriber with Dapr

  1. Install dependencies in a new terminal:
cd ./order-processor
npm install
  1. Run the Node subscriber app with Dapr:
dapr run --app-port 5001 --app-id order-processing --app-protocol http --dapr-http-port 3501 --components-path ../components -- npm run start

Run Node message publisher with Dapr

  1. Install dependencies in a new terminal:
cd ./checkout
npm install
  1. Run the Node publisher app with Dapr:
dapr run --app-id checkout --app-protocol http --components-path ../components -- npm run start
dapr stop --app-id checkout
dapr stop --app-id order-processor

Deploy to Azure for dev-test

NOTE: make sure you have Azure Dev CLI pre-reqs here and are on version 0.9.0-beta.3 or greater.

  1. Run the following command to initialize the project.
azd init --template https://github.com/Azure-Samples/pubsub-dapr-nodejs-servicebus

This command will clone the code to your current folder and prompt you for the following information:

  • Environment Name: This will be used as a prefix for the resource group that will be created to hold all Azure resources. This name should be unique within your Azure subscription.
  1. Run the following command to package a deployable copy of your application, provision the template's infrastructure to Azure and also deploy the application code to those newly provisioned resources.
azd up

This command will prompt you for the following information:

  • Azure Location: The Azure location where your resources will be deployed.
  • Azure Subscription: The Azure Subscription where your resources will be deployed.

NOTE: This may take a while to complete as it executes three commands: azd package (packages a deployable copy of your application),azd provision (provisions Azure resources), and azd deploy (deploys application code). You will see a progress indicator as it packages, provisions and deploys your application.

About

A complete microservice application featuring Dapr Pub-Sub, deployed to Azure Container Apps and Azure Service Bus Topics with dead-lettering support.

Topics

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published