Reputation: 4151
I realize I may be doing it wrong - but here's your chance to correct me!
I have a device - with id of say... 60. Device 60 is processed by Master 2.
I receive a message from the device and in the message header is its id. But at this stage my program doesnt know, or care which master the device is assigned.
I want to put all messages for device 60 into a RabbitMq Queue called "Device60" At this point nothing may be listening to that queue. Which is why I cant use an exchange b/c if nothing is listening then the message would just be dropped. I need the messages to stay in Queue60 until they are processed.
When Master 2 comes on line its has a list of say 600 devices it will process for. So it at that point it could create bindings.
How can I do a Queue to Queue binding to distribute the messages in "Device60" to the "Master2" queue?
If I am approaching this all wrong please help me understand the 'correct' way based upon the RabbitMq implementation of AMQP
Requirements are any device can send in a message(s) and they will be saved, in order, until something comes online and pulls them in.
Upvotes: 0
Views: 114
Reputation: 22682
You could use the routing key(s), by creating an exchange and a queue called Device60
bound to the exchange.
channel.queueBind("Device60","myexchange","device.60")
At this point you can publish the message,using the routing key. For example:
channel.basicPublish("myexchange","device.60",mymessage);
now the Device60
will receive the messages and store them until the consumer is online.
For the other devices it is the same:
channel.queueBind("Device50","myexchange","device.50")
and
channel.basicPublish("myexchange","device.50",mymessage);
I hope it helps.
Upvotes: 1