Thanks Michael,<br><br>I tried to declare two queues and bind each queue to the exchange. Then publish the message to the exchange, so that the message will be sent to the two queues as follows: <br><br>var connectionFactory = new ConnectionFactory();<br>
connectionFactory.HostName = "localhost";<br> <br> using (IConnection connection =<br> connectionFactory.CreateConnection())<br> {<br> using (IModel model = connection.CreateModel())<br>
{<br> model.ExchangeDeclare("MyExchange", ExchangeType.Fanout, true);<br> model.QueueDeclare("QueueOne", true);<br> model.QueueDeclare("QueueTwo", true);<br>
model.QueueBind("MyQueueOne", "MyExchange", "", false,<br> new Dictionary<string,object>());<br> model.QueueBind("MyQueueTwo", "MyExchange", "", false, <br>
new Dictionary<string,object>());<br> string message = "Hello";<br> IBasicProperties basicProperties = model.CreateBasicProperties();<br> model.BasicPublish("MyExchange", "", false, false,<br>
basicProperties, System.Text.Encoding.UTF8.GetBytes(message));<br> }<br> }<br><br>However, I am getting CS1501: No overload for method 'QueueDeclare' takes 2 arguments. My question is 1) can i declare multiple queues to then use fanout exchange and publish a message to multiple queues? 2) what is the last argument for QueueBind?<br>
<br><br>Thanks again,<br><br>Demiss<br><br><br><div class="gmail_quote">On Sat, Jul 9, 2011 at 11:30 AM, Michael Klishin <span dir="ltr"><<a href="mailto:michael.s.klishin@gmail.com">michael.s.klishin@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">2011/7/9 Demiss Zike <span dir="ltr"><<a href="mailto:habtdemis@gmail.com" target="_blank">habtdemis@gmail.com</a>></span><br>
<div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Can you point me to the right direction as to how I can write a message using RabbitMQ to multiple queues without having to open a connection for each message?</blockquote></div><br></div>Demiss,<br><br>In AMQP model messages are not written to queues. They are published to exchanges that route them to queues according to rules called "bindings". Different exchange types employ different routing rules. To route a message to multiple queues, take a look at fanout and topic exchanges. Regardless of what exchange type you choose, AMQP connections are stateful and typically long-lived: there is no need to open multiple connection for simple scenarios.<br>
<br>Have a look at these tutorials:<br><br><a href="http://www.rabbitmq.com/tutorials/tutorial-three-python.html" target="_blank">http://www.rabbitmq.com/tutorials/tutorial-three-python.html</a><br><a href="http://www.rabbitmq.com/tutorials/tutorial-five-python.html" target="_blank">http://www.rabbitmq.com/tutorials/tutorial-five-python.html</a><br>
<font color="#888888">
-- <br>MK<br><br><a href="http://github.com/michaelklishin" target="_blank">http://github.com/michaelklishin</a><br><a href="http://twitter.com/michaelklishin" target="_blank">http://twitter.com/michaelklishin</a><br><br>
</font></blockquote></div><br>