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,""); ...

Get RabbitMQ Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.