Skip to content

mtkumar123/MQTTApplication

Repository files navigation

MQTTApplication

Launching Application

In order to launch application follow these steps:

  • Make sure Docker is running, and then from the root directory of the project run docker-compose build in the terminal
  • After build process is completed run docker-compose up in the terminal
  • Application should be launched.
  • The PUBLISH_INTERVAL environment variable in .env can be changed to set the interval at which the client is publishing messages. Default publish interval is 5 seconds.

Viewing Messages Published

In order to use the REST API endpoint to view messages published and stored in MongoDB follow these steps:

  • Navigate to localhost/docs in a browser to view the FastAPI Swagger docs
  • Try out the GET /messages endpoint
  • You can also use the following command curl -X GET http://localhost/messages

Viewing MQTT Client Logs

In order to view the MQTT Client Logs either docker attach to the mqtt_client service or view them through Docker Desktop console, or lazydocker

Overview

Services

api_service

FastAPI service with the GET /messages endpoint. The endpoint reads all the published messages for the topic which is stored in MongoDB and returns those messages to the user

mqtt_client

The client application which subscribes to the topic charger/1/connector/1/session/1, and publishes messages to that topic as well. Messages are published every PUBLISH_INTERVAL. The on_message callback is used in the application to receive a published message and store it in MongoDB.

mongodb

Database service to store the published messages

mosquitto

MQTT Broker service

Enhancements

  • Pagination (skip, limit) for the GET /messages endpoint
  • Add testing
  • Add query filters to GET /messages endpoint to be able to get messages that meet certain criteria (e.g cost_cents more than a certain value)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published