[rabbitmq-discuss] RabbitMQ Consumer timeout (Alan Antonuk)

Alan Antonuk alan.antonuk at gmail.com
Fri Jul 5 16:54:32 BST 2013


On Fri, Jul 5, 2013 at 6:52 AM, Lothe_Shashank <
Lothe_Shashank at mahindrasatyam.com> wrote:

>   I modified amqp_listen.c example and instead of amqp_simple_wait_frame
> I used *amqp_simple_wait_frame_noblock *with different timeout values.
> However this API is failing immediately with return value as -13. What this
> return value means?
>

Values returned from the library should be compared to values in the
amqp_status_enum (
https://github.com/alanxz/rabbitmq-c/blob/master/librabbitmq/amqp.h#L334)
 -13 I believe AMQP_STATUS_TIMEOUT.

Is there any other way of using timeout so that if I don't receive a frame
> within say 10ms I can reject that message.
>
> amqp_simple_wait_frame_noblock() operates at a low level: it doesn't deal
with messages, it deals with frames that make up the message.  The timeout
is specifying how long to wait for a single frame before giving up.

You would need to write some logic to wait for 10 ms for a complete
message, then call amqp_basic_reject() on any message received after that
moment.


>
> Another problem I am facing with *amqp_basic_reject* API. In amqp_listen.c
> example I called this API (with requeue=1) and I got following console
> output. After that it is not able to receive any message sent by
> amqp_send_string example.
>
> 00000000: 48 65 6C 6C 6F 20 57 6F : 72 6C 64                 Hello World
> 0000000B:
> Result 0
> Frame type 1, channel 1
> Method AMQP_CHANNEL_CLOSE_METHOD
>

When you receive a AMQP_CHANNEL_CLOSE METHOD it means that a channel
exception has occurred, any consumers on that channel have been shutdown,
and the channel can no longer be used.

You should cast frame.payload.method.decoded to amqp_channel_close_t* and
examine the reply_text and error_code to see what went wrong. I'm guessing
invalid parameters were sent when you used the amqp_basic_reject function.


>
> One more problem I would like to report. I have created a client 7
> different queues with 7 different channels and bound with 7 different
> binding keys on the same connection with direct exchange. The listening
> part of these 7 queues are with 7 different threads listening for server
> input.
>

rabbitmq-c is not threadsafe.  Using a connection from more than one thread
will result in undefined behavior.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130705/07c62f41/attachment.htm>


More information about the rabbitmq-discuss mailing list