[rabbitmq-discuss] consumer received message from a queue it's not bound to? [c# rabbitmq-client, iis, servicestack]
mariusz.wojcik at hotmail.co.uk
Thu Jul 17 09:29:09 BST 2014
This probably happens because both queues are bound to the exchange to
receive a message. The reason for that may be an exchange type (fan-out for
example will send message to any bound queue) or routing-key. Looking at
your example, the routing-key used to bind queues is empty. Hence each
message post with empty routing key will be delivered to both queues. You
can run simple test to verify that. Just make sure all your queues are set
up and then publish a message but do not run any consumers. Login to
management portal to check to which queue the message has been routed to.
You can find more information about routing-key at
On Wednesday, 16 July 2014 21:45:04 UTC+1, Steve Schoon wrote:
> Here is my strange problem that I can't figure out how to fix:
> - consumer 1 write message 'a' to 'work-queue'
> - worker starts processing job 'a' (this takes a few minutes)
> - consumer 1 subscribes to 'queue-a' and try to consume 1 msg
> - consumer 2 subscribes to 'queue-b' and tries to consume 1 msg
> - worker completes processing job 'a'
> - worker writes 'a-is-done' message to 'queue-a'
> - ** CONSUMER 2 RECEIVES THE 'a-is-done' WRITTEN TO 'queue-a' EVEN
> THOUGH IT'S CONSUMING FROM 'queue-b'
> - consumer 1 receives the expected message from 'queue-a'
> - worker starts processing job 'b'
> - worker completes processing job 'b'
> - worker writes 'b-is-done' message to 'queue-'b
> 'worker' is a console application that does the following in a forever
> - reads 1 message from 'work-queue',
> - does some processing
> - write 1 message to 'queue-X' where 'X' is part of the message it
> read from 'work-queue'
> 'consumer1' and 'consumer2' are requests being handled by a a
> ServiceStack-based webservice running under IIS 7.5. The code looks like
> string queueName = request.QueueName;
> BasicDeliverEventArgs result = null;
> var connectionFactory = new ConnectionFactory();
> connectionFactory.Endpoint = new AmqpTcpEndpoint("myhostname");
> connectionFactory.UserName = "user";
> connectionFactory.Password = "pass";
> using (IConnection connection = connectionFactory.CreateConnection())
> using (IModel channel = connection.CreateModel())
> channel.ExchangeDeclare("myexchange", ExchangeType.Direct, true);
> channel.QueueDeclare(queueName, false, false, true, null);
> channel.QueueBind(queueName, "myexchange", "");
> using (Subscription sub = new Subscription(channel, "queue-a", false))
> bool rc = sub.Next(60 * 5 * 1000, out result);
> if (rc == false && result == null)
> throw new Exception("whatever");
> string msg = Encoding.UTF8.GetString(result.Body);
> How is is possible that when subscribed to 'queue-a', that a message is
> received that we placed into 'queue-b'?
> Hope this makes sense....thanks for any thoughts/suggestions.
> Steve Schoon
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rabbitmq-discuss