Legacy post. This article was written between 2016 and 2018. Software versions, commands and services mentioned here may be outdated. Check the official documentation before running anything.
The goal of this tutorial is to design a full reactive architecture that works with a Raspberry PI 3 as a μService producing temperature and humidity data.
Prerequisites
Read these posts first to understand the environment.
- Set up a Raspberry PI 3
- Interacting with DHT22 Sensor
- Push data to RabbitMQ
- Consume data from RabbitMQ
- Consume data from Reactive client
Overview
| Component | Role | Description |
|---|---|---|
| Raspberry PI 3 | μService | The Raspberry PI gets data from the sensor and pushes it over RabbitMQ |
| Mock device | μService | This mock Raspberry device provides random data |
| RabbitMQ | MOM (message-oriented middleware) | RabbitMQ is a message broker that implements the Advanced Message Queuing Protocol (AMQP). See more here |
| Reactive-server | Proxy | The server has 2 functions: it consumes data from RabbitMQ and pushes it directly to the socket |
| InfluxDB | Metric database | InfluxDB is a time series database. |
| Grafana | Data visualization | Create dynamic dashboards from an InfluxDB data source |
| Reactive-client | GUI | The GUI consumes data from Reactive-Server via WebSocket |
Start the full stack with docker-compose
Adapt the docker-compose file according to your environment
version: '2'
services:
reactive-server:
image: "jluccisano/reactive-server:latest"
environment:
- PORT=8084
- RABBITMQ_ENDPOINT=amqp://rabbit_user:rabbit_password@rabbitmq:5672/myvhost
- RABBITMQ_EXCHANGE=your_exchange_name
- RABBITMQ_QUEUE=your_queue_name
- RABBITMQ_GATEWAYID=your_gateway_id
- INFLUXDB_URL=http://influxdb:8086
- INFLUXDB_USERNAME=influx_username
- INFLUXDB_PASSWORD=influx_password
- INFLUXDB_DATABASE=influx_db_name
- INFLUXDB_RETENTION_POLICY=influx_rp_name
ports:
- "8084:8084"
links:
- "rabbitmq:rabbitmq"
- "influxdb:influxdb"
depends_on:
- "rabbitmq"
- "influxdb"
rabbitmq:
image: "rabbitmq:3-management"
environment:
- RABBITMQ_DEFAULT_USER=rabbit_user
- RABBITMQ_DEFAULT_PASS=rabbit_password
- RABBITMQ_DEFAULT_VHOST=myvhost
ports:
- "5672:5672"
- "8092:15672"
influxdb:
image: "appcelerator/influxdb"
volumes:
- './resources/init_script.influxql:/etc/extra-config/influxdb/init_script.influxql:ro'
ports:
- "8083:8083"
- "8086:8086"
grafana:
image: 'grafana/grafana'
links:
- "influxdb:influxdb"
depends_on:
- "influxdb"
ports:
- '3600:3000'
reactive-client:
image: 'jluccisano/reactive-client:1.0'
links:
- "reactive-server:reactive-server"
depends_on:
- "reactive-server"
ports:
- "8089:80"
mock-raspberry:
build:
context: ./resources
dockerfile: mock-raspberry.dockerfile
environment:
- RABBITMQ_ENDPOINT=amqp://rabbit_user:rabbit_password@rabbitmq:5672/myvhost
- RABBITMQ_EXCHANGE=your_exchange_name
- RABBITMQ_GATEWAYID=your_gateway_id
- PUBLISH_INTERVAL=60
Note: mock-raspberry is optional if you run it on a Raspberry Pi.
Run
docker-compose pull
docker-compose build
docker-compose up -d
Go to http://${YOUR_HOST}:8089
Final Result