These have been tested on Windows 10
-
Python 3.8
-
PIP
-
RabbitMQ
docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management
- OR
- https://www.rabbitmq.com/download.html
- install Erlang
- install RabbitMQ
- start rabbitmq service
- this should be kept running
-
Python VENV (OPTIONAL, but preferred to keep python installation lib clean). Launch CMD in checked out directory and execute:
python -m venv ./venv
.\venv\Scripts\activate.bat
NOTE - If you are using the virtualenv, then all solution executions should be performed in the virtual environment. Might be better to let PyCharm take care of VENV stuff.
-
Pika and pytz python package dependencies
pip install pika
for rabbitmqpip install pytz
for timezone
-
LogProducer\config.py
- APPLICATION_PATH : Path of the sensor application
- APPLICATION_NAME : Name of the sensor application
-
LogConsumer\config.py
- FILE_PATH : Directory where file is to be generated
- FILE_NAME : Name of the log file
There are two components as part of this solution.
- LogProducer
- LogConsumer
Each component will work independent of the other.
- from cmd prompt
start-log-reader.bat
- or
- Python
- cd to ./LogProducer directory
python log-reader.py {SENSOR_NAME}
- from cmd prompt
start-log-writer.bat
- or
- Python
- cd to ./LogConsumer directory
python log-writer.py
The LogProducer module performs the following operations
- Launches the sensor emulator and reads the STDIO
- Parses the packets to json format
- Saves partial packets received and combines with subsequent sensor data received. No packet loss.
- Dispatches the logs in configurable batch sizes to the RabbitMQ
The LogConsumer modules performs the following operations
- Listens to the RabbitMQ queue for log messages
- On receiving the message writes to the log file
- Multiple instances can be launched, and messages will be shared between the instances
- There WILL be read-write collisions on the file being accessed if multiple instances are launched.