O'Reilly logo

RabbitMQ Cookbook by Sigismondo Boschi, Gabriele Santomaggio

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Exchanging RabbitMQ messages with Mosquitto

In this example, we are going to create a Java proxy that gets the messages published by the example presented in the recipe Publishing messages from Android in the background and forward them to any mobile OS as seen in the recipe Binding an app from iPhone to RabbitMQ via MQTT, using an MQTT server as follows:

Exchanging RabbitMQ messages with Mosquitto

Getting ready

You need the Paho Java library client, which you can find at http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.java.git/.

How to do it…

  1. You have to create a consumer for the amq.fanout exchange:
    String myQueue = channel.queueDeclare().getQueue(); String myExchange = "amq.fanout"; channel.queueBind(myQueue,myExchange,""); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required