DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Understanding the Integration of Embedded Systems in Consumer Electronics
  • A Comparative Analysis: AWS Kinesis vs Amazon Managed Streaming for Kafka - MSK
  • Connecting the Dots: Unraveling IoT Standards and Protocols
  • Exploring IoT Integration With Wearable Devices From a Software Development Angle

Trending

  • Unlocking the Potential of Apache Iceberg: A Comprehensive Analysis
  • A Developer's Guide to Mastering Agentic AI: From Theory to Practice
  • How to Convert XLS to XLSX in Java
  • Measuring the Impact of AI on Software Engineering Productivity
  1. DZone
  2. Data Engineering
  3. Big Data
  4. Apache Kafka and MQTT: End-to-End IoT Integration

Apache Kafka and MQTT: End-to-End IoT Integration

Want to learn more about IoT integration from the edge to the data center? Check out this post on using Apache Kafka and MQTT for end-to-end IoT integration.

By 
Kai Wähner user avatar
Kai Wähner
DZone Core CORE ·
Updated Jul. 18, 19 · Analysis
Likes (15)
Comment
Save
Tweet
Share
87.2K Views

Join the DZone community and get the full member experience.

Join For Free

Kafka and MQTT are two complementary technologies. Together, they allow us to build IoT end-to-end integration from the edge to the data center — no matter if on-premise or in the public cloud. I talk about this topic in greater detail at the Kafka Summit SF in San Francisco in October 2018: "Processing IoT Data from End to End with MQTT and Apache Kafka".

As preparation for the talk, I created two demo projects on GitHub. I want to share these here. The full talk (slide deck + video recording + demo) is available on the website of Kafka Summit: Kafka MQTT Integration.

Motivation for Using Apache Kafka and MQTT Together

MQTT is a widely used ISO standard (ISO/IEC PRF 20922) publish-subscribe-based messaging protocol. MQTT has many implementations, such as Mosquitto or HiveMQ. For a good overview, see Wikipedia's comparison of MQTT brokers. MQTT is mainly used for Internet of Things scenarios (like connected cars or smart home devices). But, it is also used more and more in mobile devices due to its support for WebSockets.

However, MQTT is not built for high scalability, longer storage, or easy integration to legacy systems. Apache Kafka is a highly scalable distributed streaming platform. Kafka ingests, stores, processes, and forwards high volumes of data from thousands of IoT devices.

Therefore, MQTT and Apache Kafka are a perfect combination of end-to-end IoT integration from the edge to the data center (and back, of course, i.e. bi-directional).

Let's take a look at two different alternatives for building this integration. Both solutions allow highly scalable and mission-critical integration of IoT scenarios. However, they use different concepts, including trade-offs.

MQTT Broker, Apache Kafka, and Kafka Connect MQTT Connector

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

Image title

In this approach, you pull the data from the MQTT Broker via Kafka Connect to the Kafka Broker. You can leverage any features of Kafka Connect, such as built-in fault tolerance, load balancing, Converters, and Simple Message Transformations (SMT) for routing/filtering/etc., scaling different connectors in one Connect worker instance and other Kafka Connect related benefits.

Here is the GitHub project, including demo script, to try it out by yourself:

Apache Kafka + Kafka Connect + MQTT Connector + Sensor Data

MQTT Proxy and Apache Kafka (no MQTT Broker)

As an alternative to using Kafka Connect, you can leverage Confluent MQTT Proxy. You will need to integrate IoT data from IoT devices directly without the need for an MQTT Broker:

Image title

In this approach, you push the data directly to the Kafka broker via the Confluent MQTT Proxy. You can scale MQTT Proxy easily with a Load Balancer (similar to Confluent REST Proxy). The huge advantage is that you do not need an additional MQTT Broker in the middle. This reduces efforts and costs significantly. It is a better approach for pushing data into Kafka.

Here is the Github project, including demo script, to try it out by yourself:

Deep Learning UDF for KSQL for Streaming Anomaly Detection of MQTT IoT Sensor Data.

Both approaches have their trade-offs. The good thing is that you have the choice. Choose the right tool and architecture for your use case!

Conclusion: MQTT and Apache Kafka Are Complementary and Integrate Well

Both, MQTT and Apache Kafka have great benefits for their own use cases. But, none of them are the single allrounder for everything. The combination of both makes them very powerful and a great solution to build IoT end-to-end scenarios from the edge to data center and back.

At Kafka Summit, I will share many more details and content, including the following:

  • How to integrate MQTT and Apache Kafka end-to-end (not just talking about connectivity, but also about data processing, filtering, routing, etc.)
  • When to choose Kafka Connect and MQTT Broker vs. MQTT Proxy without MQTT Broker
  • Slides and video recording of talk and live demo

By the way, if you want to see an IoT example with Kafka sink applications, like Elasticsearch/ Grafana, please take a look at the project "Kafka and KSQL for Streaming IoT Data from MQTT to the Real Time UI." This example demonstrates how to realize the integration with ElasticSearch and Grafana via Kafka Connect.

MQTT kafka IoT Integration Data (computing)

Published at DZone with permission of Kai Wähner, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Understanding the Integration of Embedded Systems in Consumer Electronics
  • A Comparative Analysis: AWS Kinesis vs Amazon Managed Streaming for Kafka - MSK
  • Connecting the Dots: Unraveling IoT Standards and Protocols
  • Exploring IoT Integration With Wearable Devices From a Software Development Angle

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!