MQTT (Message Queuing Telemetry Transport,) is a message protocol based on the pub/sub model with the advantages of compact message structure, low resource consumption, and high efficiency, which is suitable for IoT applications with low bandwidth and unstable network environments.
This session will introduce MQTT on Pulsar, which allows developers users of MQTT transport protocol to use Apache Pulsar. I will share the architecture, principles and future planning of MoP, to help you understand Apache Pulsar's capabilities and practices in the IoT industry.
5. As a MQTT user
•Rewrite the client
•MQTT API wrapper
• MQTT connector
6. With MoP
•No need to change existed MQTT client code, no matter it’s
Java or C++, etc.
•No need to write a new connector for Pulsar.
•MQTT Producer & Pulsar Consumer or Pulsar producer &
MQTT consumer.
7. Proxy/gateway?
MQTT Producer Proxy/Gateway
MQTT
requests
Pulsar Broker
Pulsar
requests Bookie
MoP is a plugin, which means MoP can access all the internal resources of
broker instead sending requests by a client.
MoP
Bookie
BK client
Pulsar Broker
MQTT Producer
11. Load the protocol handler
Create an yml
f
ile under META-INF/services/, building the project to NAR package
name: mqtt
description: MQTT Protocol Handler
handlerClass: io.streamnative.pulsar.handlers.mqtt.MQTTProtocolHandler
When a broker starts, it will
- Load all NAR packages under protocolHandlerDirectory
- Select the package whose name is in messagingProtocols
- Initialized the Java class speci
f
ied in handlerClass
- Verify if the name could be accepted by ProtocolHandler#accept.
13. Install MoP
• Compile -> package -> generate *.nar package.
• Add some extra con
f
igs to broker.conf or standalone.conf.
•
• Restart Pulsar broker
14. MoP Proxy
Extend MoP to multiple nodes to achieve horizontally scalable services
1. MQTT clients connect to MoP Proxy.
2. MoP Proxy sends lookup topic to pulsar cluster, searching for topic owner broker URL。
3. Pulsar cluster gives back topic owner broker URL to MoP Proxy。
4. MoP Proxy connects to owner broker,MQTT Clients begin to communicate with owner broker.