• Stars
    star
    201
  • Rank 193,992 (Top 4 %)
  • Language
    Shell
  • License
    Apache License 2.0
  • Created about 6 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Internet of Things Integration Example => Apache Kafka + Kafka Connect + MQTT Connector + Sensor Data

Apache Kafka + Kafka Connect + MQTT Connector + Sensor Data

This demo shows an Internet of Things (IoT) integration example using Apache Kafka + Kafka Connect + MQTT Connector + Sensor Data.

This project does not include any source code as Kafka Connect allows integration with data sources and sinks just with configuration.

Example configuration and step-by-step guide can be found below. If you want to find more details about Kafka + MQTT integration, take a look at my slides from Kafka Summit 2018 in San Francisco: IoT Integration with MQTT and Apache Kafka. The video recording is available on the website of Kafka Summit for free: Kafka MQTT Integration - Video Recording.

Architecture: Sensor Data via MQTT Broker and Kafka Connect MQTT Connector to Kafka Cluster

This project focuses on the integration of MQTT sensor data into Kafka via MQTT Broker and Kafka Connect for further processing:

As alternative to using Kafka Connect, you can also leverage Confluent MQTT Proxy to integrate IoT data from IoT devices directly withou the need for a MQTT Broker. See Deep Learning UDF for KSQL for Streaming Anomaly Detection of MQTT IoT Sensor Data for an example and source code.

If you want to see the other part (integration with sink applications like Elasticsearch / Grafana), please take a look at the project "KSQL for streaming IoT data", which shows how to realize the integration with ElasticSearch via Kafka Connect.

Live Demo Video - MQTT with Kafka Connect and MQTT Proxy

If you want to see Apache Kafka / MQTT integration in a video, please check out the following 15min recording showing a demo my two Github examples:

Apache Kafka + MQTT Integration

Kafka Connect Configuration (No Source Code Needed!)

Here is the full configuration for the MQTT Connector for Kafka Connect's Standalone mode, which we use with Confluent CLI for a local setup:

            name=MqttSourceConnector1
            connector.class=io.confluent.connect.mqtt.MqttSourceConnector
            tasks.max=1
            mqtt.server.uri=< Required Configuration >
            mqtt.topics=< Required Configuration >

For distributed mode, you can use the same configuration with REST API:

            curl -s -X POST -H 'Content-Type: application/json' http://localhost:8083/connectors -d '{
                "name" : "< Required Configuration >",
            "config" : {
                "connector.class" : "io.confluent.connect.mqtt.MqttSourceConnector",
                "tasks.max" : "1",
                "mqtt.server.uri" : "< Required Configuration >",
                "mqtt.topics" : "< Required Configuration >",
                "kafka.topics" : "< Required Configuration >"
            }
            }'

The documentation explains the differences between standalone and distributed Kafka Connect mode. In short: Standalone mode is the simplest mode, where a single process is responsible for executing all connectors and tasks. Distributed mode is used in most production scenarios and provides scalability and automatic fault tolerance for Kafka Connect. You can also use distributed mode for local development leveraging its advantages like a REST API even if you just have one single Connect instance (and you can scale it later easily without complex changes). We will use distributed mode in this project therefore.

Confluent documentation contains more details about installing and using Confluent's MQTT Connector.

How to run it?

Requirements

  • Java 8

  • Confluent Platform 5.0+ (Confluent Enterprise if you want to use the Confluent MQTT Proxy, Confluent Open Source if you just want to run the KSQL UDF and send data via kafkacat instead of MQTT)

  • MQTT Client and Broker (this demo uses Mosquitto)

  • Confluent MQTT Connector (a Kafka Connect based connector to send and receive MQTT messages) - Very easy installation via Confluent Hub, just one command:

              confluent-hub install confluentinc/kafka-connect-mqtt:1.2.3
    
  • Optional: MQTT.fx (a nice, simple UI to test MQTT pub/sub; not required - just makes life more comfortable)

The code is developed and tested on Mac and Linux operating systems. As Kafka does not support and work well on Windows, this is not tested at all.

Step-by-step demo

Follow these steps to configure the MQTT Connector, start all components, generate MQTT sensor data and consume it from a Kafka consumer.

More Repositories

1

kafka-streams-machine-learning-examples

This project contains examples which demonstrate how to deploy analytic models to mission-critical, scalable production environments leveraging Apache Kafka and its Streams API. Models are built with Python, H2O, TensorFlow, Keras, DeepLearning4 and other technologies.
Java
816
star
2

hivemq-mqtt-tensorflow-kafka-realtime-iot-machine-learning-training-inference

Real Time Big Data / IoT Machine Learning (Model Training and Inference) with HiveMQ (MQTT), TensorFlow IO and Apache Kafka - no additional data store like S3, HDFS or Spark required
Jupyter Notebook
386
star
3

ksql-udf-deep-learning-mqtt-iot

Deep Learning UDF for KSQL for Streaming Anomaly Detection of MQTT IoT Sensor Data
Java
282
star
4

tensorflow-serving-java-grpc-kafka-streams

Kafka Streams + Java + gRPC + TensorFlow Serving => Stream Processing combined with RPC / Request-Response
Java
142
star
5

python-jupyter-apache-kafka-ksql-tensorflow-keras

Making Machine Learning Simple and Scalable with Python, Jupyter Notebook, TensorFlow, Keras, Apache Kafka and KSQL
Jupyter Notebook
94
star
6

ksql-fork-with-deep-learning-function

Deep Learning UDF for KSQL, the Streaming SQL Engine for Apache Kafka with Elasticsearch Sink Example
Java
77
star
7

ksql-machine-learning-udf

Confluent KSQL Addon - User Defined Function (UDF) for Machine Learning
Java
12
star
8

ksql-apache-kafka-quickstart-step-by-step-example

KSQL Step-by-step tutorial using the basic functions of Apache Kafka's Streaming SQL Engine
10
star
9

MavenCamelScala

A working
8
star
10

kafka-streams-machine-learning-docker-microservice

A Kafka Streams Microservice (using Machine Learning) deployed as a Docker Container
Java
8
star
11

kafka-connect-smt-string-filter

Single Message Transformation (SMT) for Kafka Connect to Filter String Messages
Java
7
star
12

camel-infoq

Introduction Demo of Apache Camel (InfoQ article)
Java
6
star
13

Apache-Kafka-PipelineAI-Machine-Learning-Infrastructure

Machine Learning Infrastructure leveraging Apache Kafka Ecosystem, PipelineAI, Kubernetes and Docker
5
star
14

kafka-streams-python-integration-with-jep

Calling Python Code / Script in Kafka Streams with Jep (TensorFlow Keras Example)
2
star
15

tensorflow-tfserving-cloud-apache-kafka-streams

Model Inference with Apache Kafka, Kafka Streams and a TensorFlow model deployed to TF-Serving (Google Cloud ML Engine)
Java
2
star
16

musiccrawler

Erlang
1
star
17

gradlePlayApp

1
star
18

keras-tensorflow-model-inference-kafka-streams-ksql-dl4j

Keras Tensorflow Model deployed for Inference in Kafka Streams / KSQL microservice via Deeplearning4j
Java
1
star
19

tensorflow-kafka-confluent-google-cloud

Deep Learning at Extreme Scale with TensorFlow and Apache Kafka / Confluent on Google Cloud
Jupyter Notebook
1
star
20

camel

Mirror of Apache Camel
Java
1
star
21

AirportWeather

Apache Camel example that can find out the weather at an airport.
Java
1
star