ballerina/mqtt Ballerina library
This module provides an implementation to interact with MQTT servers via MQTT client and listener.
MQTT is a lightweight, publish-subscribe, machine to machine network protocol for message queue/message queuing service.
Publisher and subscriber
A MQTT publisher is a MQTT client that publishes messages to the MQTT server. When working with a MQTT client, the first thing to do is to initialize the client. For the publisher to work successfully, an active MQTT server should be available.
The code snippet given below initializes a publisher client with the basic configuration.
publish api of this client, messages can be sent to the MQTT server.
A MQTT subscriber is a client responsible for reading messages from one or more topics in the server. When working with a MQTT subscriber, the first thing to do is initialize the subscriber. For the subscriber to work successfully, an active MQTT server should be available.
The code snippet given below initializes a subscriber with the basic configuration.
This subscriber can be used in the
mqtt:Service to listen to messages in
mqtt:Caller can be used to indicate that the application has completed processing the message by using