[rabbitmq-discuss] a shared queue problem

Valentin Bernard vbernard42 at gmail.com
Fri Aug 19 15:28:19 BST 2011


The routing key determines the way your exchange will route your
messages to your queues. What you are doing is binding one queue to
one exchange with two routing keys, "aa" and "bb" -- that is, the
message will be routed to your queue if you send a message with the
routing key "aa" or "bb".

Then, you have two clients consuming your queue. In that case, the
messages will be delivered in a round-robin fashion: your first client
will get the first message, then your second client will get the
second message, and so on.

What you probably want to do is creating two queues, each with one
routing key, and make your clients consume only one of these queues.



On Aug 19, 2:55 pm, 陆云龙 <l... at wawame.cn> wrote:
> on java api guide page ,you can find that If several clients want to share a queue with a well-known name, this code would be appropriate:
> channel.exchangeDeclare(exchangeName, "direct", true);
> channel.queueDeclare(queueName, true, false, false, null);
> channel.queueBind(queueName, exchangeName, routingKey);
> when i do that one routingKey is aa,another is bb,start aa first,then start bb,when i send message by routing bb,the first routingKey aa client receives the message,but the message i want to send to routingKey bb client.
> start aa routingKey client--->start bb routingKey client--->send routingKey bb message--->routingKey aa receive the message--->send routingKey bb message--->routingKey bb receive the message--...
> why message is not arrive the correct client by routingKey???
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-disc... at lists.rabbitmq.comhttps://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss

More information about the rabbitmq-discuss mailing list