[rabbitmq-discuss] BasicGet ignoring routing key . Exchange is Direct
Alvaro Videla
videlalvaro at gmail.com
Thu Jan 2 20:47:11 GMT 2014
Hi,
Replies inline:
On Thu, Jan 2, 2014 at 6:56 PM, Patrick Long <pat at munkiisoft.com> wrote:
> We are using the C# .NET client library.
>
> I create a channel like so
>
> channel.ExchangeDeclare(workExchangeName, ExchangeType.Direct);
Here you create an exchange, not a channel. The channel in AMQP is
used to send commands to the broker, like queue declare or exchange
declare, and to also send/receive messages.
>
> Then bind a queue like
>
> channel.QueueBind(this.WorkQueueName, workExchangeName,
> BuildRoutingKey(buildNumber));
>
> Today I was trying to debug a failing message from a different environment.
> I took the message's JSON from that server, via the Management UI, and
> manually created a message on my local machine, again via the Management UI.
> There was no option to set a specific RoutingKey, it created one for me with
> the same name as the queue 'WorkQueue'.
>
> The local RabbitMQ had a couple of existing messages with a RoutingKey of
> 'Development:STACK_1_WEBSERVER_V2:1:2.9.0.0'
>
> When I call channel.BasicGet(this.WorkQueueName, false) in a loop it
> dequeues all three messages even though the channel was created to look at a
> queue and exchange with the routing key of
> 'Development:STACK_1_WEBSERVER_V2:1:2.9.0.0'
>
> Any idea why it would be ignoring the RoutingKey?
basicGet (or basicConsume for that matter), don't look at routing keys
when getting messages. Again, the channel knows nothing about routing
keys used for the bindings above. basicGet or basicConsume will just
get the messages from the queue. That is, if a message was routed to
the queue, with whatever routing key, then that message can be
consumed from that queue using either basicGet or basicConsume. BTW,
unless you want to read one message at a time, then is better to use
basicConsume.
You can read more here: http://www.rabbitmq.com/tutorials/amqp-concepts.html
Regards,
Alvaro
>
> Thanks
>
>
> --
> Patrick Long - Munkiisoft Ltd
>
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
>
More information about the rabbitmq-discuss
mailing list