liveBook · Manning

Video viewed message

As explained in Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform

A video viewed message is an application message indicating that a user has started watching or viewed a video.

A video viewed message is an application event that tells another microservice a user has started watching or viewed a video. The video-streaming microservice emits it, while the history microservice records the viewing history. That history can support personal review, resume-watching, and recommendations. section 5.4 section 10.7.5

Common delivery patterns include:

  • Send the message directly with an HTTP POST to the history service at http://history/viewed, using JSON such as {"videoPath": "..."}. Handle success and failure callbacks separately. section 5.7.3
  • Publish the message indirectly through RabbitMQ. A sender publishes JSON containing videoPath to the viewed queue, and the history service consumes, stores, and acknowledges it. section 5.8.6
  • Treat the message as an event so additional microservices can respond later without changing the video-streaming service, preserving decoupling and extensibility. section 10.7.5

Emitting a view during streaming

When the video-streaming service forwards a requested video stream, it calls broadcastViewedMessage(messageChannel, videoId). The message carries the video identifier, and the history service can record it independently. section 10.7.5

How Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform covers it

How deep it goes
Implements JSON payloads, HTTP POST callbacks, RabbitMQ publishing, queue consumption, database insertion, and message acknowledgement.
Examples
Uses the /viewed endpoint, the videoPath JSON field, the viewed RabbitMQ queue, and a streaming-route broadcast.
What it assumes
Assumes familiarity with microservices and JSON, while demonstrating the message sender, receiver, queue, persistence, and acknowledgement flow.
What you can do after
Build it from scratch using Node.js HTTP requests or RabbitMQ publishers and consumers to record video views.
How it connects
Connects microservices, HTTP POST, RabbitMQ, message queues, event-driven programming, and viewing history.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Bootstrapping Microservices, Second Edition: With Docker, Kubernetes, GitHub Actions, and Terraform. The section links point to the parts of the book it draws on.