A bridge between a FROST Server and Apache Kafka, written in Java
Requirements:
- A working JDK. This program is not guaranteed to work properly with JDK versions below 8u171.
- Maven
- Git
On Debian/Ubuntu systems, just run sudo apt install default-jdk maven git
.
- Clone this repository via
git clone https://github.com/olivermliu/java-mqtt-kafka-bridge.git
. cd java-mqtt-kafka-bridge
- If necessary, adjust the parameters in the jmkb.properties file (see below for more information).
mvn clean install
(Note: Tests require the configuration in jmkb.properties to be valid and all services (Kafka, FROST) to be running. To skip tests, runmvn clean install -DskipTests
).- Run the program with the generated jar:
java -jar target/*.jar
.
Set configurables in the jmkb.properties file. Please note: URIs require a <protocol>://<address>:<port>
format.
Currently, configurables are:
frostServerURI
: the URI from which to get the MQTT messages of the FROST-Server. Requirestcp://
as protocol. Usually port 1883.kafkaBrokerURI
: the URI to which to send Kafka records. With Kafka Landoop, use the port defined under "Kafka Broker". Usually port 9092 andhttp://
as protocol.schemaRegistryURI
: the URI from which to get Avro schemas. With Kafka Landoop, use the port defined under "Schema Registry". Usually port 8081 andhttp://
as protocol.format
: the format in which to send MQTT messages to Kafka. Currently, the formatsavro
andjson
are supported.
- Use
Ctrl+C
to terminate the program. This ensures that the MQTT Client and Kafka Producer disconnect properly. - You can use a program like
screen
to open a virtual terminal and run the bridge there.
Test data are provided in the password-protected archive TestData.7z. With this, the functionality of the program can be tested. Please make sure the bridge is running before you start step 4. You will need Python 3 to run the scripts and p7zip-full to extract the test data.
- Run
sudo apt install p7zip-full python3 python3-pip
to install Python 3, pip and 7z. - Run
python3 -m pip install pandas requests
to install required modules. - Run
7z x TestData.7z
in the directory ofTestData.7z
to extract the scripts and test data. Enter the password when prompted. - Run
python3 CreateThing.py
, thenpython3 CreateDatastream.py
, thenpython3 AddObservationsToDatastream.py
. - Test data should have been successfully published to FROST.