This project demonstrates the use of Dapr for pub/sub messaging with multiple subscribers using different ways to subscribe and different programming languages.
publisher/
: Java publisher applicationdeclarative-subscriber/
: JavaScript subscriber using declarative subscriptionsprogrammatic-subscriber/
: Python subscriber using programmatic subscriptionsstreaming-subscriber/
: Go subscriber using streaming subscriptionscommon/
: Common resources and configurationsdapr.yaml
: Dapr multi-app run configurationskaffold.yaml
: Skaffold configuration for deployment
cd publisher
mvn clean package
cd declarative-subscriber
npm install
cd programmatic-subscriber
pip install -r requirements.txt
cd streaming-subscriber
go mod download
go build
Follow the steps in the quickstart guide to install Kubernetes and Conductor.
Install Redis using Helm:
helm repo add bitnami https://charts.bitnami.com/bitnami && helm repo update && helm install redis bitnami/redis --set cluster.enabled=false --set replica.replicaCount=0 --set fullnameOverride=dapr-dev-redis
To install Skaffold, use the following command:
brew install skaffold
To deploy the applications to a Kubernetes cluster:
skaffold dev
This command will build the Docker images, deploy the applications, and watch for changes.
To run all applications using Dapr multi-app run:
dapr run -f dapr.yaml
You can test the publisher by sending a POST request:
curl -X POST http://localhost:5001/pubsub/orders \
-H "Content-Type: application/json" \
-d @order.json
Or use the Dapr CLI to publish a message:
dapr publish --publish-app-id publisher --pubsub pubsub --topic orders --data '{"orderId": "123"}'
Or use test.rest
file from your IDE.
- Subscription Overview: View all subscription types (declarative, programmatic, and streaming) in one consolidated dashboard in Conductor
-
Component Metrics: Analyze detailed metrics for each subscriber application:
- Message processing and error rates
- Latency statistics
-
Application Networking: Examine networking metrics for each application:
- Incoming and outgoing traffic rates
- Network latency
-
To view received messages and application behavior: check the logs from skaffold or dapr CLI.
- Make changes to the application code or Dapr configurations (for Java, you must rebuild the Jar files).
- If using
skaffold dev
, changes will be automatically detected and redeployed. - If using dapr run approach, restart the Dapr multi-app run after making changes.