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