quickstarts/pub_sub/go/sdk/README.md

2.1 KiB

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 generates messages of a specific topic, while subscribers listen for messages of specific topics.

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:

  • Go client message generator checkout

And one subscriber:

  • Go subscriber order-processor

Run Go message publisher with Dapr

  1. Navigate to the directory and install dependencies:
cd ./checkout
go build app.go
  1. Run the Go publisher app with Dapr:
cd ./checkout
dapr run --app-id checkout --app-protocol http --dapr-http-port 3500 --components-path ../../../components -- go run app.go

Run Go message subscriber with Dapr

  1. Navigate to the directory and install dependencies:
cd ./order-processor
go build app.go
  1. Run the Go subscriber app with Dapr:
cd ./order-processor
dapr run --app-port 6001 --app-id order-processor --app-protocol http --dapr-http-port 3501 --components-path ../../../components -- go run app.go
dapr stop --app-id checkout
dapr stop --app-id order-processor