Mule MQTT Connector 1.0x

Author: Kartik Patil


MQTT stands for Message Queuing Telemetry Transport. It is an OASIS standard messaging protocol for the Internet of Things (IoT). It is designed as an extremely lightweight publish / subscribe messaging transport that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth.

MQTT communication works as a publish and subscribe system. Devices publish messages on a specific topic. All devices that are subscribed to that topic receive the message.

To know more about MQTT visit

MQTT Connector

Till Date MQTT Connector is available for MQTT V3 protocol and not for V5.

  • Create a mule project and add MQTT Connector in palette from Exchange.
MQTT Config

Create MQTT3 Config in global elements.

  • Connections :
    • MQTT3 URL Connection

This type of connection requires the full MQTT broker url as one value.

  • MQTT3 Fail-Over Connection

There are certain deployment schemas that consist of multiple brokers working together to provide clients with several connection endpoints. When there is more than one available server that the client can connect to, there are two possible scenarios: either each MQTT server operates separately, or they might work together and share a state (cluster mode), in which case you might want to specify how the MQTT client behaves in the event of a reconnection.

When you provide a failover server list, the connector can iterate over the list until it successfully establishes a connection with one of the provided endpoints.

  • MQTT3 Form Connection

This type of connection requires us to provide the MQTT broker url as 3 different  values (Protocol, Host, Port) .

  • General
    • Required Libraries:

Add Recommended Libraries from the config button.

  • Client id generator : Select client id generator method.
  • Client id : set any client id.
  • Username :  username to connect with broker (keep blank if its open connection )
  • Password : password to connect with broker (keep blank if its open connection )
  • URL : broker URL 

Test Your Connection and make sure it’s successful as shown below

  • LWT (Last Will and Testament)

LWT is set to ensure that a message is sent to all of the subscribers of a specific LWT topic if the client disconnects temporarily or permanently from the broker. The LWT message is sent when the connection to the broker is established again.

  • Topic : kind of key under which we are sending data.
  • Body : message body
  • QoS : 

Messages are delivered at most one time (“fire and forget”) and delivery is not guaranteed.


Messages are delivered correctly at least one time. The message could be delivered more than once.


Messages are sent once and delivery is ensured.

  • Is retained : default false. If it’s set to true then the broker stores the last message marked as retained that arrived at a specific topic. If no listeners are subscribed to a matching topic at the time the message is sent, the broker stores the message until a listener connects to that topic. Then, the broker delivers the listener to the last message retained for that topic.

Test Your Connection and make sure it’s successful.

MQTT Operations

This MQTT Connector has only 2 operations as MQTT is a PubSub Module.

  1. Publish 

Operation that allows the user to publish a single MQTT3 message under a particular topic

  • Drag publish connector next to HTTP Listener. And configure general section as shown below 
  • Advance : set reconnection strategy
  • Error mapping : to map errors.
  1. On New Message (Subscribe)

It’s a source for mule flow which allows the user to capture a message under a particular topic.

  • Drag On New Message connector and configure the general section as shown below.
  • Opposite to the publish connector we can subscribe to multiple topics with one On New Message connector.
  • Advance : for reconnection strategy 
  • Redelivery : With the Redelivery policy we can redeliver messages multiple times. In this object store is used to track redelivery count. 

Thanks for Reading !!!

For any queries or suggestions please contact Kartik Patil –

We use cookies on this site to enhance your user experience. For a complete overview of how we use cookies, please see our privacy policy.