A message is a discrete communication between microservices, carrying an event notification or command. A video-streaming service sends a “Viewed” message so a history service can record viewing activity in its own database. section 5.4 section 5.6.1
Choose the messaging style according to how the sender and receiver must interact:
- Use direct messaging when one service targets another by name, needs an immediate success or failure response, or must sequence dependent actions. HTTP provides this interaction, but couples both services tightly. section 5.6.1 section 5.9
- Use indirect messaging when a service broadcasts an event to zero or more interested recipients or when sender and receiver should evolve independently. RabbitMQ provides this interaction. section 5.9
Recording a viewed video
Start the example with `cd chapter-5/example-2` and `docker compose up --build`, play the video at `http://localhost:4001/video`, and inspect the Docker Compose output. Each refresh should produce a “Viewed” message and a new record in the history database’s `videos` collection. Shut it down afterward with `docker compose down`. section 5.7.5
Table 5.2 When to use each type of communication (view table figure)
Compare direct HTTP and indirect RabbitMQ messaging by recipient selection, response requirements, sequencing, orchestration, broadcasting, and service coupling. section 5.9






