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:
list_topic_subscriptions- Dapr runtime calls this method to get list of topics the application is subscribed to.on_topic_event- Defines how the application handles the topic event.
Note: Make sure to use latest version of proto bindings.
Before you run the example make sure local redis state store is running by executing:
docker ps
- To run the example we need to first build the examples using the following command:
cargo build --examples- Run the multi-app run template:
dapr run -f .- Stop with
ctrl + c
- Run the subscriber with dapr
dapr run --app-id rust-subscriber --app-protocol grpc --app-port 50051 -- cargo run --example pubsub-subscriber- Run the publisher with dapr
dapr run --app-id rust-publisher --app-protocol grpc -- cargo run --example pubsub-publisher