This documentation is for WSO2 Enterprise Service Bus version 5.0.0. For the latest ESB, view the latest WSO2 Enterprise Integrator documentation.

All docs This doc
Skip to end of metadata
Go to start of metadata


This sample demonstrates how the MQTT connector publishes a message on a particular topic and how a MQTT client that is subscribed to that topic receives it.


  • You need to have the following downloaded.

Building the sample

For consumer ESB 
  • Copy the following client libraries to the < ESB_HOME>/repository/components/lib directory.
    • axis2-transport-mqtt-1.0.0.jar
    • mqtt-client-0.4.0.jar
  • Add the XML configuration for the inbound endpoint as follows:

    <inboundEndpoint xmlns="" name="test" sequence="TestIn" onError="TestIn" protocol="mqtt" suspend="false">
          <parameter name="sequential">true</parameter>
          <parameter name="mqtt.connection.factory">mqttFactory</parameter>
          <parameter name="">localhost</parameter>
          <parameter name="mqtt.server.port">1883</parameter>
          <parameter name="">esb.test2</parameter>
          <parameter name="mqtt.subscription.qos">2</parameter>
          <parameter name="content.type">application/xml</parameter>
          <parameter name="mqtt.session.clean">false</parameter>
          <parameter name="mqtt.ssl.enable">false</parameter>
          <parameter name="mqtt.subscription.username">elil1</parameter>
          <parameter name="mqtt.subscription.password">e13</parameter>
          <parameter name="">my</parameter>
          <parameter name="mqtt.blocking.sender">false</parameter>
    <sequence xmlns="" name="TestIn">
       <log level="full"/>
For publisher ESB 

Run the following command to use the mosquito publisher:

mosquitto_pub -h -t esb.test2 -m "<msg><a>Testing123</a></msg>"

Executing the request

After you perform the required configuration changes,

  • Start the ESB and the mosquito publisher.
  • Start the mosquitto subscriber by executing the following command:

    mosquitto_sub -h -t esb.test2

Analyzing the output

On the console you will see the following:

Esb subscriber 

Mosquitto subscriber

  • No labels