[rabbitmq-discuss] Create exchanges and queues beforehand
Stefano Ghio
steghio at eng.it
Tue Nov 15 14:39:13 GMT 2011
>If you need to hear about previous messages, you should
>create queue beforehand.
Done but with issues as my problem lies there:
/
/>A queue is identified by a name. The same name= the same
>queue. You can bind multiple exchanges to a queue though,
>and receive data from multiple exchanges on a single queue.
I need to declare one queue for every receiver and bind it to the same exchange but I don't know how many there will be, furthermore everything has to be done at runtime.
Say I have a client CLIENT0 at t0 which declares:
- queue A
- exchange EX
From its code, I bind EX-A with routing "client.something":
ConnectionFactory factory = new ConnectionFactory();
factory.setHost("localhost");
connection = factory.newConnection();
channel = connection.createChannel();
channel.exchangeDeclare("EX", "topic");
channel.queueDeclare("A", false, false, false, null);
channel.queueBind("A", "EX", "client.something");
Now if I send a message:
[...]
channel.basicPublish("EX", "client.*", null, message.getBytes());
it gets queued in queue A and I can read it with:
[...]
QueueingConsumer consumer = new QueueingConsumer(channel);
channel.basicConsume("A", true, consumer);
Later at t1, two more clients CLIENT1, CLIENT2 show up and declare:
- queues B, C
on the same exchange EX
From their code, I bind EX-B with routing "client.else" and EX-C with routing "another.something" so that I can send messages to both CLIENT0 and CLIENT1 by using routing "client.*", and to CLIENT0 and CLIENT2 using routing "*.something".
If I now send another message from CLIENT0, it only gets queued in queue A and never goes in queue B or C. Declaring and binding all three queues at time t0 instead works and messages are delivered correctly to the right clients.
My question is:
How can I dynamically declare and bind queues to already existing exchanges so that already running senders can continue sending messages as they did before and have them delivered properly?
Back to my example, I'd like CLIENT0 to keep sending messages routing them with "client.*" and see those messages added in the newly created queue B too after CLIENT1 has declared and binded it. Maybe I need some sort of refresh in CLIENT0?
Any help is much appreciated,
have a nice day
--
Dr. Stefano Ghio - ENG Engineering Italy
Website: http://groglogs.blogspot.com/
*If you received this message but you are not its recipient, please
ignore it and warn me, thank you.*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20111115/43f9e636/attachment.htm>
More information about the rabbitmq-discuss
mailing list