Micheal, I looked at the links you sent me and based my new approach on them. And, I did the following (and no errors but it's not doing what i wanted):<br><br>I declared two queues q1 and q2 and bind them to a fanout exchange. Then I published the message to the exchange.<br>
<br>On the receiving end of my application, I declared another queue (q3) and bind it to the same exchange. Then when I consume messages I consume from q3 via the exchange I declared. But I don't expect to get any messages since I send the messages to queues q1 and q2 but requesting a message from q3. The problem is, I still get messages. I could be asking a lot but please bear with me. Please look at the code I have and point me to the right direction:<br>
<br>//EmitLog.cs<br>using System;<br>using RabbitMQ.Client;<br><br>class EmitLog {<br> public static void Main(string[] args) {<br> ConnectionFactory factory = new ConnectionFactory();<br> factory.HostName = "localhost";<br>
using (IConnection connection = factory.CreateConnection())<br> using (IModel channel = connection.CreateModel()) {<br> channel.ExchangeDeclare("logs", "fanout");<br> channel.QueueDeclare("q1", false, false, false, null);<br>
channel.QueueDeclare("q2", false, false, false, null);<br> channel.QueueBind("q1", "logs", "");<br> channel.QueueBind("q2", "logs", "");<br>
<br> string message = (args.Length > 0) ? string.Join(" ", args)<br> : "info: Hello World!";<br> byte[] body = System.Text.Encoding.UTF8.GetBytes(message);<br>
channel.BasicPublish("logs", "", null, body);<br> Console.WriteLine(" [x] Sent {0}", message);<br> }<br> }<br>}<br><br><br><br>//ReceiveLogs.cs<br>using System;<br>
using RabbitMQ.Client;<br>using RabbitMQ.Client.Events;<br><br>class ReceiveLogs {<br> public static void Main(string[] args) {<br> ConnectionFactory factory = new ConnectionFactory();<br> factory.HostName = "localhost";<br>
using (IConnection connection = factory.CreateConnection())<br> using (IModel channel = connection.CreateModel()) {<br> channel.ExchangeDeclare("logs", "fanout");<br><br> //string queue_name = channel.QueueDeclare();<br>
//string queue_name2 = channel.QueueDeclare();<br> //channel.QueueDeclare("q1", false, false, false, null);<br> channel.QueueDeclare("q3", false, false, false, null);<br>
<br> //channel.QueueBind("q2", "logs", "");<br> channel.QueueBind("q3", "logs", "");<br> QueueingBasicConsumer consumer = new QueueingBasicConsumer(channel);<br>
//channel.BasicConsume("q2", true, consumer);<br> channel.BasicConsume("q3", true, consumer);<br> <br> Console.WriteLine(" [*] Waiting for logs." +<br>
"To exit press CTRL+C");<br> while(true) {<br> BasicDeliverEventArgs ea =<br> (BasicDeliverEventArgs)consumer.Queue.Dequeue();<br><br> byte[] body = ea.Body;<br>
string message = System.Text.Encoding.UTF8.GetString(body);<br> Console.WriteLine(" [x] {0}", message);<br> }<br> }<br> }<br>}<br><br>Thanks,<br><br><div class="gmail_quote">
On Sat, Jul 9, 2011 at 1:00 PM, 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;">
<br><br><div class="gmail_quote"><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><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
However, I am getting CS1501: No overload for method 'QueueDeclare' takes 2 arguments. </blockquote></div><div> <br>According to <a href="http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v2.5.1/rabbitmq-dotnet-client-2.5.1-user-guide.pdf" target="_blank">http://www.rabbitmq.com/releases/rabbitmq-dotnet-client/v2.5.1/rabbitmq-dotnet-client-2.5.1-user-guide.pdf</a>, QueueDeclare takes at least 4 arguments: name, durability, exclusivity and auto-deletion setting. Why don't you just follow examples from that user guide, it seems to be pretty extensive and includes code examples.<br>
<br></div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">My question is 1) can i declare multiple queues to then use fanout exchange and publish a message to multiple queues?</blockquote>
</div><div><br>Yes.<br> </div><div class="im"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204, 204, 204);padding-left:1ex">2) what is the last argument for QueueBind?</blockquote>
</div></div><br>Binding arguments. More about bindings can be found in AMQP 0.9.1 spec document (introductory chapters are a pretty easy read) <a href="http://bit.ly/hw2ELX" target="_blank">http://bit.ly/hw2ELX</a>.<div><div>
</div><div class="h5"><br clear="all">
<br>-- <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>
</div></div></blockquote></div><br>