Task 2

Utility programs

The mini application relies on several programs/services already running on the PC before other parts of the application start.

The mini application shall at least use a message broker and optionally a database.

Message broker

The mini application will rely on RabbitMQ as a message broker with support for MQTT messages and websocket transport enabled.

https://www.rabbitmq.com/

Reasons for selecting RabbitMQ are:

  • good support for various programming languages
  • quality of the documentation
  • browser-based admin tools.
  • support of websockets

For interacting with RabbitMQ programmatically several Python and Javascript libraries have been tried. Here are the ones I found most promising:

Python

Only libraries with Asyncio have been considered.

https://pypi.org/project/asyncio-mqtt/#side-by-side-with-web-frameworks

Javascript

This library seems to be reasonably well documented:

https://www.emqx.com/en/blog/connect-to-mqtt-broker-with-websocket

(this link provides another link from where the Javascript libary can be downloaded)

Database

As a database I choose to install postgresql. The mini application may use the database for persistent storage.

Following the documentation the installation was done with adminitstrator privileges.

There have been some obstacles on my Windows installation though:

  • Firewall rules (TCP ports) had to set
  • Antivirus software blocked access and had to be disabled for postgresql related programs

To get familiar with PostgreSQL I recommend this book:

https://www.practicalsql.com/

(worked through chapters 1 – 11 of the book and found it extremely well written and even entertaining)

For interacting with PostgreSQL programmatically I found these libraries useful and well documented:

Python

The library psycop3 supports synchronous and asynchronous operation.

https://www.psycopg.org/psycopg3/


Checking program status

To ensure that helper programs such as RabbitMQ and/or PostgreSQL are running already before other parts of the mini project start I found the Python library psutils is quite helpful.

Rather than checking the status of such programs/services manually (eg.: using built-in Windows tools) psutils allows to do this programmatically.

https://psutil.readthedocs.io/en/latest/

Python module checkRunningPrograms_Services.py defines two functions programsRunning and servicesRunning to check programmatically whether a spefic program or service is running.


Resources

For some demo programs refer to GitHub:

RabbitMQ / MQTT message broker

Some test programs demonstrating how to use some Python libraries to publish / subscribe to RabbitMQ / MQTT.

https://github.com/michaelbiester/MQTT

PostgreSQL

https://github.com/michaelbiester/PostgreSQL