components/pubsub.yaml:apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: pubsub
namespace: default
spec:
type: pubsub.redis
version: v1
metadata:
- name: redisHost
value: redis:6379
- name: redisPassword
value: ""
发布消息(HTTP API):curl -X POST http://localhost:3500/v1.0/publish/pubsub/orders \
-H "Content-Type: application/json" \
-d '{"id": 1, "sku": "A-100"}'
应用订阅(HTTP 路由约定):POST /orders
Content-Type: application/json
{"id":1,"sku":"A-100"}
运行应用(示例):dapr run --app-id app --app-port 3000 --resources-path ./components -- node app.js

发表评论 取消回复