Skip to content
An AMQP Adapter for MQTT
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

AMQP Adapter for MQTT

This is an AMQP adapter for MQTT. It is designed internally to connect to the ClearBlade MQTT Broker.
NOTE: This adapter is still in beta and only supports basic functionality of the AMQP protocol. It only supports AMQP v0.9.1 and it is only tested with the RabbitMQ Java Client.


  • Clone this repository
  • You will need to have Eclipse Paho installed on your system. Please follow instructions given at
  • After installing paho, run make clean and then make
  • After successful compilation, you can start the adapter by running ./main
  • The adapter listens for incoming connections on port 5672


AMQP clients can connect to this adapter and the adapter will convert and forward the AMQP packets to the ClearBlade MQTT Broker. Make sure you have the RabbitMQ Java Client installed. It can be found at You must use the exact syntax of the RabbitMQ Java client as described below:

Connecting to the Adapter

import java.util.concurrent.TimeoutException;

import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.Channel;

String username = "CLEARBLADE_AUTH-TOKEN";
String systemKey = "CLEARBLADE-SYSTEM-KEY";
String mqttClientID = "CLIENT-ID";
String mqttPort = "CLEARBLADE-MQTT-PORT";
String adapterIP = "ADAPTER-IP";

String password = systemKey + "-" + mqttClientID + "-" + messagingURL + "-" + mqttPort;

ConnectionFactory factory = new ConnectionFactory(); 
factory.setUri("amqp://" + username + ":" + password + "@" + adapterIP + ":5672");

Connection conn = factory.newConnection();
Channel channel = conn.createChannel();

Replace the CLEARBLADE_AUTH-TOKEN, CLEARBLADE-SYSTEM-KEY, CLIENT-ID, CLEARBLADE-MESSAGING-URL, CLEARBLADE-MQTT-PORT and ADAPTER-IP with your own. An example of the CLEARBLADE-MESSAGING-URL can be and that of the CLEARBLADE-MQTT-PORT would be 1883. You can either get a ClearBlade AuthToken manually at or you can have your application or device fetch it using one of our SDKs at

Publishing Messages

String topic = "YOUR_TOPIC";
String message = "YOUR_MESSAGE";

channel.basicPublish("", topic, null, message.getBytes());

Replace YOUR_TOPIC and YOUR_MESSAGE with the topic and message of your choice.

Subscribing to Topics

import com.rabbitmq.client.AMQP;
import com.rabbitmq.client.Consumer;
import com.rabbitmq.client.DefaultConsumer;
import com.rabbitmq.client.Envelope;

String topic = "YOUR_TOPIC";

Consumer consumer = new DefaultConsumer(channel) {
	public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, byte[] body)
	throws IOException {
	  String message = new String(body, "UTF-8");
		System.out.println(" [x] Received '" + message + "'");
channel.basicConsume(topic, true, consumer);

Replace YOUR_TOPIC with the topic of your choice.

Disconnecting from the Adapter

You can’t perform that action at this time.