This folder contains two Go files that use the Go SDK to invoke the Dapr Pub/Sub API.
- Dapr installed
Note: sub/sub.go contains both AddTopicEventHandler (used for subscribe of messages) and AddBulkTopicEventHandler (used for bulksubscribe of messages)
dapr run --app-id sub \
--app-protocol http \
--app-port 8080 \
--dapr-http-port 3500 \
--log-level debug \
--resources-path ./config \
go run sub/sub.goNote: pub/pub.go contains both PublishEvents (used for publish of messages) and PublishEvent (used for bulkPublish of messages)
dapr run --app-id pub \
--log-level debug \
--resources-path ./config \
go run pub/pub.godapr stop --app-id sub
(lsof -i:8080 | grep sub) | awk '{print $2}' | xargs kill== APP == 2023/03/29 21:36:07 event - PubsubName: messages, Topic: neworder, ID: 82427280-1c18-4fab-b901-c7e68d295d31, Data: ping
== APP == 2023/03/29 21:36:07 event - PubsubName: messages, Topic: newbulkorder, ID: cc13829c-af77-4303-a4d7-55cdc0b0fa7d, Data: multi-pong
== APP == 2023/03/29 21:36:07 event - PubsubName: messages, Topic: newbulkorder, ID: 0147f10a-d6c3-4b16-ad5a-6776956757dd, Data: multi-ping