This project extends the distributed Energy Management System by introducing Asynchronous Communication and Event-Driven Architecture. While the first stage focused on user/device management, this stage adds real-time monitoring capabilities.
The system now processes streams of energy data from smart meter simulators using RabbitMQ as a message broker. It also implements cross-service synchronization to ensure data consistency across the distributed database landscape.
In addition to the User and Device microservices (from Assignment 1), the system now includes:
- RabbitMQ (Message Broker):
- Decouples the system components.
- Manages two primary queues:
sensor-data-queue(for high-volume metering data) andsync-queue(for system-wide consistency events).
- Monitoring Microservice (Consumer):
- Role: Subscribes to the
sensor-data-queue. - Logic: Receives energy measurements every 10 minutes, aggregates them into hourly energy consumption totals, and stores them in the Monitoring Database.
- Role: Subscribes to the
- Device Data Simulator (Producer):
- A standalone application that mimics a smart energy meter.
- Generates realistic consumption patterns (e.g., peak usage in evenings, low usage at night) and pushes JSON payloads to RabbitMQ.
- Configurable: Reads target Device IDs from a configuration file.
To maintain consistency between loose-coupled microservices, I implemented an event-based sync mechanism:
- User Sync: When an Admin creates a User in the User Service, a message is published. The Device Service consumes this to map future devices to that user.
- Device Sync: When a Device is created, a message is published so the Monitoring Service knows to expect data for that device ID.
The Client interface now includes specific visualization tools:
- Historical Data: Clients can select a date from a calendar.
- Visualization: Displays energy consumption charts (Bar/Line graphs) with:
- X-Axis: Hours of the day.
- Y-Axis: Energy value (kWh).
- Backend: Java Spring Boot (Microservices)
- Middleware: RabbitMQ (AMQP Protocol)
- Frontend: Angular (with Chart.js / ng2-charts)
- Database: PostgreSQL / MySQL (Per-service database pattern)
- DevOps: Docker, Docker Compose, Traefik