Dapr Technical Architecture

https://docs.dapr.io/concepts/overview

Installing the Dapr CLI Scaffolding Tool

https://docs.dapr.io/zh-hans/getting-started/install-dapr-cli

Initializing the Dapr Runtime with Containers

https://docs.dapr.io/zh-hans/getting-started/install-dapr-selfhost

dapr init

Initializing the Dapr Runtime Offline Without Containers

dapr init -s

Initializing the Dapr Runtime from an Offline Bundle

https://docs.dapr.io/zh-hans/operations/hosting/self-hosted/self-hosted-airgap/

dapr init --from-dir C:\daprbundle

Opening the Default Initialization Directory

explorer "$env:USERPROFILE\.dapr"
explorer "%USERPROFILE%\.dapr"

Viewing Dapr Runtime Status with the Dashboard

dapr dashboard

Configuring Distributed Events with Pub/Sub

/components/redis-pubsub.yaml

Redis-Based Pub/Sub Configuration

apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: pubsub
spec:
  type: pubsub.redis
  version: v1
  metadata:
  - name: redisHost
    value: localhost:6379
  - name: redisPassword
    value: ""

RabbitMQ-Based Pub/Sub Configuration

/components/rabbitmq-pubsub.yaml
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
  name: pubsub
spec:
  type: pubsub.rabbitmq
  version: v1
  metadata:
  - name: host
    value: "amqp://guest:guestpwd@localhost:5672"
  - name: durable
    value: "false"
  - name: deletedWhenUnused
    value: "false"
  - name: autoAck
    value: "false"
  - name: reconnectWait
    value: "0"
  - name: concurrency
    value: parallel

Starting the Sidecar and Application with the Dapr Command

dapr run --app-id myapp --dapr-http-port 3500 --dapr-grpc-port 50001 --app-port 5000 --log-level debug --config ./configuration/config.yaml --components-path ./components dotnet run

Starting the Sidecar and Application with Aspire

dotnet add package Aspire.Hosting.Dapr
var pubsub = builder.AddDaprPubSub("pubsub", new DaprComponentOptions { LocalPath = "./DaprComponents/" });

var productService = builder.AddProject<Projects.HelloWorld_ProductService>("productservice")
    .WithReference(identityService)
    .WithDaprSidecar()
    .WithReference(pubsub);

RabbitMQ Pub/Sub Configuration

var username = builder.AddParameter("username", secret: true);
var password = builder.AddParameter("password", secret: true);

var messaging = builder.AddRabbitMQ("messaging", username, password);

// Service consumption
builder.AddProject<Projects.ExampleProject>()
       .WithReference(messaging);