<div dir="ltr">Just realized the example is not clear - the value of 'queueName' on the MQTT side is 'builds' - the same as the value for the 'routingKey' on the AMQP side used for channel.queueBind.<div><br></div><div>Dejan<br><br>On Wednesday, April 16, 2014 6:29:41 PM UTC-4, Dejan Glozic wrote:<blockquote class="gmail_quote" style="margin: 0;margin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir="ltr"><div>I am banging my head on my desk the whole afternoon trying to figure this out. I am trying to publish a message into an MQTT topic using Eclipse MQTT Paho client, and receive it using RabbitMQ AMQP Java client.</div><div><br></div><div>I am using RabbitMQ for Windows, version 3.2.4.</div><div><br></div><div>From what I was reading, MQTT plug-in will publish into the default 'amq.topic' exchange, and I can bind a queue to that exchange and start listening.</div><div><br></div><div>When I publish a message into the exchange using AMQP client, the AMQP client on the receiving end will get it.</div><div><br></div><div>When I publish a message using MQTT client, another MQTT client on the receiving end will get it.</div><div><br></div><div>But for the love of God I cannot get the cross-protocol to work.</div><div><br></div><div>Here is the MQTT client that publishes:</div><div><br></div><div><font size="2"><p align="LEFT"><br></p><p align="LEFT">MqttClient client;</p></font><p align="LEFT"><font size="2">         </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">try</font></font></b><font size="2"> {</font></p><font size="2"></font><p align="LEFT"><font size="2">                          client = </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">new</font></font></b><font size="2"> MqttClient(</font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">"tcp://"</font></font><font size="2">+host+</font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">":<wbr>1883"</font></font><font size="2">, </font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">"pahomqttpublish1"</font></font><font size="2">);</font></p><font size="2"><p align="LEFT">                            client.connect();</p></font><p align="LEFT"><font size="2">                          MqttMessage message = </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">new</font></font></b><font size="2"> MqttMessage(messageText.<wbr>getBytes());</font></p><font size="2"><p align="LEFT">                       client.publish(queueName, message);</p></font><p align="LEFT"><font size="2">                   System.</font><i><font color="#0000c0" size="2"><font color="#0000c0" size="2">out</font></font></i><font size="2">.println(</font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">" [x] Sent to MQTT topic '"</font></font><font size="2"> +queueName+</font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">"': "</font></font><font size="2">+ message + </font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">"'"</font></font><font size="2">);                         </font></p><font size="2"><p align="LEFT">                      client.disconnect();                 </p></font><p align="LEFT"><font size="2">          } </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">catch</font></font></b><font size="2"> (MqttException e) {</font></p><font size="2"></font><p align="LEFT"><font size="2">                        </font><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2">    // </font></font><b><font color="#7f9fbf" size="2"><font color="#7f9fbf" size="2">TODO</font></font></b><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2"> Auto-generated catch block</font></font></p><font color="#3f7f5f" size="2"><font color="#3f7f5f" size="2"></font></font><font size="2"><p align="LEFT">                      e.printStackTrace();</p><p>}</p><p><br></p><p>And here is the AMQP client that is supposed to receive it:</p><p>public static final String QUEUE_NAME="workerQueue";<br></p><p align="LEFT"><font size="2"></font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">public</font></font></b><font size="2"> </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">static</font></font></b><font size="2"> </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">void</font></font></b><font size="2"> main(String[] args) </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">throws</font></font></b><font size="2"> IOException, InterruptedException {</font></p><p align="LEFT"><font size="2">   ConnectionFactory factory = </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">new</font></font></b><font size="2"> ConnectionFactory();</font></p><p><font size="2">   factory.setHost(</font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">"localhost"</font></font><font size="2">);</font></p><font size="2"><p>   Connection connection = factory.newConnection();</p><p>   Channel channel = connection.createChannel();</p></font><p align="LEFT"><font size="2">   channel.queueDeclare(QUEUE_<wbr>NAME</font><font size="2">, </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">true</font></font></b><font size="2">, </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">false</font></font></b><font size="2">, </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">false</font></font></b><font size="2">, </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">null</font></font></b><font size="2">);</font></p><p><font size="2">   channel.queueBind(QUEUE_NAME</font><font size="2">,  </font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">"amq.topic"</font></font><font size="2">, </font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">"builds"</font></font><font size="2">);</font></p><p><font size="2">   System.</font><i><font color="#0000c0" size="2"><font color="#0000c0" size="2">out</font></font></i><font size="2">.println(</font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">" [*] Waiting for messages. To exit press CTRL+C"</font></font><font size="2">);</font></p><font size="2"><p><br></p></font><p align="LEFT"><font size="2">   QueueingConsumer consumer = </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">new</font></font></b><font size="2"> QueueingConsumer(channel);</font></p><p align="LEFT"><font size="2">   channel.basicConsume(QUEUE_<wbr>NAME, <b><font color="#7f0055"><font color="#7f0055">true</font></font></b>, consumer);</font></p><p align="LEFT"><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">   while</font></font></b><font size="2"> (</font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">true</font></font></b><font size="2">) {</font></p><font size="2"><p>      QueueingConsumer.Delivery delivery = consumer.nextDelivery();</p></font><p align="LEFT"><font size="2">      String message = </font><b><font color="#7f0055" size="2"><font color="#7f0055" size="2">new</font></font></b><font size="2"> String(delivery.getBody());</font></p><font size="2"><p>      String routingKey = delivery.getEnvelope().<wbr>getRoutingKey();</p></font><p align="LEFT"><font size="2">      System.</font><i><font color="#0000c0" size="2"><font color="#0000c0" size="2">out</font></font></i><font size="2">.println(</font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">" [x] Received '"</font></font><font size="2"> + routingKey + </font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">"':'"</font></font><font size="2"> + message + </font><font color="#2a00ff" size="2"><font color="#2a00ff" size="2">"'"</font></font><font size="2">);</font></p><p align="LEFT">   }</p><font size="2"><p align="LEFT">}</p><p align="LEFT"><br></p><p align="LEFT">The client above will receive the message when published into "amq.topic" exchange by another AMQP client.</p><p align="LEFT">Anything stupid and obvious I am missing?</p><p align="LEFT">Dejan</p></font><p><br></p></font></div></div></blockquote></div></div>