MQTT on Pulsar (MoP) is a protocol handler developed by StreamNative to natively support the MQTT protocol on the Pulsar broker. By adding the MoP protocol handler to your existing Pulsar cluster, you can now migrate your existing MQTT applications and services to Pulsar without modifying the code.
This section describes how to enable MoP on StreamNative Platform.
sn-platform
chart: 1.4.0 or higherpulsar-operator
chart: 0.10.0 or higherTo enable MoP within a Kubernetes cluster, you can set broker.mop.enabled
and broker.mop.proxyEnabled
to true
in the values.yaml
YAML file as follows and use the helm upgrade
command to update the resource.
Enable MoP.
(Optional) If you want to enable authentication and authorization, set the broker.mop.authenticationEnabled
and broker.mop.authorizationEnabled
to true
in the values.yaml
YAML file as follows.
MoP inherits all the authentication and authorization methods from the Pulsar broker configurations.
Apply the new configuration.
You can use any client that supports the MQTT protocol to publish data into Pulsar. This section shows how to use the Eclipse Mosquitto MQTT CLI tool to connect to a Pulsar cluster and then produce and consume messages to and from the Pulsar cluster.
To connect to a Pulsar cluster using the Eclipse Mosquitto MQTT CLI tool, follow these steps.
Deploy an Eclipse Mosquitto Pod.
a. Define an Eclipse Mosquitto as below and save the YAML file (pod.yaml
).
b. Apply your configurations.
Subscribe to messages from the Pulsar cluster.
a. Open a new terminal window and enter the Eclipse Mosquitto Pod.
b. Subscribe to messages from the Pulsar cluster.
If you have enabled authentication, use the token as the password. The username can be any string.
Publish messages to the Pulsar cluster.
a. Open a new terminal window and enter the Eclipse Mosquitto Pod.
b. Publish messages to the Pulsar cluster.
If you have enabled authentication, execute the following command.