< Previous Challenge - Home - Next Challenge >
In this challenge, you’re going to add Dapr state management in the TrafficControl service to store vehicle information.
Dapr includes APIs that support stateful, long-running services with key/value storage. Services can use these APIs to leverage a variety of popular state stores, without adding or learning a third party SDK.
Furthermore, the Dapr state management building block provides several other features that would otherwise be complicated and error-prone to build yourself:
The following diagram shows the high level architecture:
Right now, this is all you need to know about this building block. If you want to get more detailed information, read introduction to the state management building block.
You will need to modify the services to use the Dapr state management block.
TrafficControlService
(TrafficController
class) so it saves the state of a vehicle (VehicleState
class) using the Dapr state management building block after vehicle entry.TrafficControlService
(TrafficController
class) so it reads and updates the state of a vehicle using the Dapr state management building block after vehicle exit.This challenge targets the operation labeled as number 3 in the end-state setup:
TrafficControlService
has been modified to use the Dapr state management building block when saving vehicle state on vehicle entry.TrafficControlService
has been modified to use the Dapr state management building block when reading & updating vehicle state on vehicle exit.dapr_redis
container that is used as the state-store in the default Dapr installation.
docker exec -it dapr_redis redis-cli
keys
and hgetall
to validate data inside the Redis cache store.az redis show --name <redis cache name> -g <resource group> --query "[hostName,sslPort,primaryKey]"
Redis Cache
resource and click on Console
to run similar commands as you did in the local Redis cache instance.