RabbitMQ powered live temperature dashboard using Spring-Boot….

Dashboard-live data

Here you can see temperature values are indicating above line chart.Here i send temperature to rabbitmq data by scheduler which my application itself by random manner in every 5 seconds. After get this temperature data and chat is generating.

First of all let’s see the rabbitmq functionality…

What is rabbitmq?


RabbitMQ is a message broker that use with Advance Message Queue Protocol (AMQP). This will help your communicate with your applications. RabbitMQ also called as middleware build using Erlang, due it can be both micro-services and an app. RabbitMQ support multiple protocols, here is the protocol that RabbitMQ support:

How RabbitMQ work?

Exchange is an algorithm that decide which queue that will store the message
(get message from producer, include in queue of consumer). Each consumer get it’s own Queue based on logic that you use, there are 4 type of logic that you can use in Exchange:
- Direct Exchange: Will be direct to queue based on a message routing key
- Fanout Exchange: Will publish to all queues that have same routing key
- Topic Exchange: Will publish to all queue that have same routing key and routing pattern specified in the binding
- Headers Exchange: Header means header in sending a file http, like when you send Image the header is ‘image/*’

Why do we need to use RabbitMQ?

Decouple: What means by decoupling is separate the core components of the application. This is what any application that implement micro-services wanted. Because their application will be maintainable and improve it’s quality of Single Responsibility Principle.

Flexibility: Because the application has been decoupled, so the application will be flexible enough for being develop to the next phase. But no only that flexible, because if you are using RabbitMQ, you will be able to connect 2 different apps/service that written by different app, these application will talk to each other by the help of a “translator” which is MOM.

Another benefit of using RabbitMQ:
- Highly Available Queue
- Multi-Protocol
- Many Client
- Clustering
- Management UI
- Tracing (Using dashboard can trace support)
- Plugin System (Extend core broker functionality in a variety of ways)

Let’s do the implementation..

Please go to the spring initializr. For the dependencies, web, rabbitmq,web socket.

In the application properties should be as follows.

server.port=9001 // this is optionalspring.rabbitmq.host=localhostspring.rabbitmq.port=5672spring.rabbitmq.username=rootspring.rabbitmq.password=1234livetemperature.rabbitmq.exchange=livetemperature.exchangelivetemperature.rabbitmq.queue=temp.queuelivetemperature.rabbitmq.routingkey=temp.routingkey


Rabbitmq for the send data and receive data

Websocket for real time chart drawing


RabbitMQ receiver


Here for the demo i will used dummy temperature data. its generated by the scheduler with random number generator every 5 seconds.

Data send to the RabbitMQ server

For the UI, it should be the html template. it as follows

You can show the data from http://localhost:9001/dashboard


This is the source code link- download

Thank you

BSc. (Hons.) in Software Engineering | University of Kelaniya, Sri Lanka| https://github.com/Isuru40 | https://science.kln.ac.lk/tunits/setu