Skip to content

Latest commit

 

History

History
144 lines (126 loc) · 5.53 KB

File metadata and controls

144 lines (126 loc) · 5.53 KB

Pub/Sub Example

This is a simple example that demonstrates Dapr's pub/sub capabilities. To implement pub/sub in your rust application, you need to implement AppCallback server for subscribing to events. Specifically, the following two methods need to be implemented for pub/sub to work:

  1. list_topic_subscriptions - Dapr runtime calls this method to get list of topics the application is subscribed to.
  2. on_topic_event - Defines how the application handles the topic event.

Note: Make sure to use latest version of proto bindings.

Running

Before you run the example make sure local redis state store is running by executing:

docker ps
  1. To run the example we need to first build the examples using the following command:
cargo build --examples
  1. Run the multi-app run template:
dapr run -f .
  1. Stop with ctrl + c

Running without multi-app

  1. Run the subscriber with dapr
dapr run --app-id rust-subscriber --app-protocol grpc --app-port 50051 -- cargo run --example pubsub-subscriber
  1. Run the publisher with dapr
dapr run --app-id rust-publisher --app-protocol grpc -- cargo run --example pubsub-publisher