On 14 Jul 2015 at 23:26:39, Eric Fernandez Merchan (
mercha...@gmail.com) wrote:
> So, as I just want to send direct messages between an android
> app and a desktop app that got the same useID, I can:
>
> a) Make publishers send messages with the same topic and then
> have to guess and code somehow the queue name they are consuming
> from:
>
> channel.queueDeclare(QUEUE_NAME, ...)
> channel.basicConsume(QUEUE_NAME, true, consumer);
>
> b) Make them publish with a custom topic (the userID for example),
> so the comsumers have just to get the queue name like this ?
> channel.exchangeDeclare(EXCHANGE_NAME (USERID in my case),
> "topic");
> String queueName = channel.queueDeclare().getQueue();
> channel.queueBind(queueName, EXCHANGE_NAME, "”);
Make them publish to a topic such as /devices/${DEVICE_ID}.
In your (AMQP 0-9-1) consumer, declare a queue (can be server-named),
bind it to amq.topic (topic exchange used by MQTT plugin unless configured
otherwise) with routing key = "devices.*” (for example) and consume from that
queue.
There is NO need to use separate exchange, one exchange per device, etc. You already
know what exchange is used and what routing key are used by your Android publisher.
Just consume that data.
To respond to Android clients, take the idea from Tutorial 6 [1]
and possibly adjust it a bit to your needs (chances are, there will be next to no adjustment).
1.
http://www.rabbitmq.com/getstarted.html