[rabbitmq-discuss] listnening on two queues

Michael Klishin mklishin at gopivotal.com
Sat Feb 22 12:47:44 GMT 2014

On 22 Feb 2014, at 14:55, Jano Kianicka <kianicka123jano at yahoo.com> wrote:

> 1. When we use routing messages through a custom exchange and bindings, and if there is some error, for instance wrong queue name or wrong routing key given, is it possible to obtain some error response from RabbitMQ server? Up to now what I did testing, the messages were just silently lost.

Publish messages as mandatory and those that cannot be routed will
be returned using basic.return:


also, take a look at publisher confirms, as mandatory publishing does not cover all the possible failure


> 2. We are thinking about having clients and producers controlled by special set of queues. So one component will listen on two or more queues. One will deliver business process messages which carry data processing information, but other queue will carry control commands. This control queue must have higher priority even when main business process queue is full of messages. I did the following test:
> /* Initialization of consuming properties - consumer priority */
>   amqp_table_t queue_table;
>   amqp_table_entry_t  entry;
>   entry.key = amqp_cstring_bytes("x-priority");
>   entry.value.kind =  AMQP_FIELD_KIND_U32;
>   entry.value.value.u32 = 1;
>   queue_table.num_entries = 1;
>   queue_table.entries = &entry;
> /* Start listening on two queues */
>   while (1) {
>           amqp_basic_consume(conn, 1, amqp_cstring_bytes(queuename1), amqp_empty_bytes, 0, 0, 0, amqp_empty_table);
>         die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming");
>           amqp_basic_consume(conn, 1, amqp_cstring_bytes(queuename2), amqp_empty_bytes, 0, 0, 0, queue_table);
>         die_on_amqp_error(amqp_get_rpc_reply(conn), "Consuming");
> But when this consumer test was executed, the following error occured:
> queue2 x-priority: 1 
> Consuming: a socket error occurred
> When there was amqp_empty_table for both, it was consuming messages from both queues but in a random manner, sometimes even 4 messages from one and then three messages from the other. We need to have higher priority on the control queue.

See Tutorial 2 that explains basic.qos:

and consumer priorities (RabbitMQ 3.2+):

As for the socket error, you need to inspect it as well as RabbitMQ log to see
what happened.


Software Engineer, Pivotal/RabbitMQ

More information about the rabbitmq-discuss mailing list