[rabbitmq-discuss] Quick question: Writing to multiple queues
Demiss Zike
habtdemis at gmail.com
Sat Jul 9 18:29:38 BST 2011
Thanks Michael,
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:
var connectionFactory = new ConnectionFactory();
connectionFactory.HostName = "localhost";
using (IConnection connection =
connectionFactory.CreateConnection())
{
using (IModel model = connection.CreateModel())
{
model.ExchangeDeclare("MyExchange", ExchangeType.Fanout,
true);
model.QueueDeclare("QueueOne", true);
model.QueueDeclare("QueueTwo", true);
model.QueueBind("MyQueueOne", "MyExchange", "", false,
new Dictionary<string,object>());
model.QueueBind("MyQueueTwo", "MyExchange", "", false,
new Dictionary<string,object>());
string message = "Hello";
IBasicProperties basicProperties =
model.CreateBasicProperties();
model.BasicPublish("MyExchange", "", false, false,
basicProperties,
System.Text.Encoding.UTF8.GetBytes(message));
}
}
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?
Thanks again,
Demiss
On Sat, Jul 9, 2011 at 11:30 AM, Michael Klishin <
michael.s.klishin at gmail.com> wrote:
> 2011/7/9 Demiss Zike <habtdemis at gmail.com>
>
>> 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?
>
>
> Demiss,
>
> 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.
>
> Have a look at these tutorials:
>
> http://www.rabbitmq.com/tutorials/tutorial-three-python.html
> http://www.rabbitmq.com/tutorials/tutorial-five-python.html
> --
> MK
>
> http://github.com/michaelklishin
> http://twitter.com/michaelklishin
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20110709/e5d04a77/attachment.htm>
More information about the rabbitmq-discuss
mailing list