Icon for EMQXIcon for Apache Kafka

EMQX and Apache Kafka

Integrates withCurated

Overview

EMQX integrates natively with Apache Kafka, allowing organizations to bridge the gap between IoT device messaging and stream processing. This integration is commonly used in smart manufacturing, connected vehicles, and large-scale telemetry systems.

Integration Architecture

IoT Devices → MQTT → EMQX → Rule Engine → Kafka → Consumers
                                      ↓
                                (Analytics, Storage, ML)

Data Flow:

  1. Devices publish MQTT messages to EMQX
  2. EMQX Rule Engine filters/transforms messages using SQL
  3. Selected messages are published to Kafka topics
  4. Kafka consumers process data for analytics, ML, or storage

Configuration

The integration is configured through EMQX's SQL-based Rule Engine:

SELECT
  payload.temperature as temp,
  payload.humidity as humidity,
  clientid as device_id
FROM
  "factory/sensors/+"
WHERE
  payload.temperature > 50

Then add a Kafka action to publish matching messages to a topic.

Use Cases

  • Smart Manufacturing: Stream sensor data to Kafka for real-time OEE calculation
  • Connected Vehicles: Aggregate telemetry for fleet analytics
  • Energy Monitoring: Feed smart meter data to Kafka for demand forecasting
  • Predictive Maintenance: Route vibration/temperature data to ML pipelines

Tradeoffs

Advantages:

  • No custom code required
  • In-flight filtering reduces Kafka load
  • Built-in buffering and retry logic

Considerations:

  • Adds latency (typically <10ms)
  • Rule Engine syntax learning curve
  • Requires monitoring both systems

Alternatives

For simpler use cases, consider:

  • Direct Kafka clients: If devices can use Kafka protocol directly
  • Kafka Connect MQTT connector: For pull-based integration
  • Node-RED: For visual flow-based routing