In this assignment, you're going to add Dapr publish/subscribe messaging to send messages from the TrafficControlService to the FineCollectionService.
The publish/subscribe pattern allows your microservices to communicate asynchronously with each other purely by sending messages. In this system, the producer of a message sends it to a topic, with no knowledge of what service(s) will consume the message. A message can even be sent if there's no consumer for it.
Similarly, a consumer will receive messages from a topic without knowledge of what producer sent it. This pattern is especially useful when you need to decouple microservices from one another. See the diagram below for an overview of how this pattern works with Dapr:
For this hands-on assignment, this is all you need to know about this building block. If you want to get more detailed information, read the overview of this building block in the Dapr documentation.
To complete this assignment, you must reach the following goals:
- The TrafficControlService sends
SpeedingViolation
messages using the Dapr pub/sub building block. - The FineCollectionService receives
SpeedingViolation
messages using the Dapr pub/sub building block. - RabbitMQ is used as pub/sub message broker that runs as part of the solution in a Docker container.
This assignment targets number 2 in the end-state setup:
Open the source code folder in VS Code. Then open the Dapr documentation for publish / subscribe and start hacking away. Make sure you use the RabbitMQ pub/sub component and spin up a RabbitMQ container to act as message broker.
To get step-by-step instructions to achieve the goals, open the step-by-step instructions:
Make sure you stop all running processes and close all the terminal windows in VS Code before proceeding to the next assignment.
Go to assignment 4.