[rabbitmq-discuss] rabbitmq-c close channel already but still get message from the channel

Alan Antonuk alan.antonuk at gmail.com
Fri Jun 14 18:13:15 BST 2013

Inlined below.


On Fri, Jun 14, 2013 at 3:18 AM, 3k4b251 <314992959 at qq.com> wrote:

> <http://rabbitmq.1065348.n5.nabble.com/file/n27390/list_queue.jpg>
> you can see  tha   I  get  four  messages  in the  queue -----fb_test_2
> ,so  I  will  use  function wait_simple_frame()  to  receive   msg in a
> thread.
> in  the void main(){};
> Scene 1:
> I  open  the  channel  1  :  amqp_channel_open(conn,1);
> ask consumer   :amqp_basic_consume(conn,1...);
> I get  the  message from  queue---fb_test_2
> Scene 2:
> I  did  nothing;
> I  block   in the  wait_simple_frame()  and nothing receive;
> Scene 3:
> I  open the channel  1:  amqp_channel_open(conn,1);
> I ask  consumer :  amqp_basic_consume(conn,1...);
> then I close the channel immediately :  amqp_channel_close(conn,1);
> but what happens,  I  still  receive  the message... I don't  think  I
> should receive them.  what' the problem?

You're seeing the result of the network buffering. As soon as the broker
received the basic.consume method, if there are messages in the queue, the
broker will start sending queued messages to the client. Even though you
immediately closed the channel, because it takes time to send the
channel.close method across the network, the broker will still have time to
send messages to the client before the channel is closed. You are seeing
messages that are sent before the broker closes the channel.

This is expected behavior.

> --
> View this message in context:
> http://rabbitmq.1065348.n5.nabble.com/rabbitmq-c-close-channel-already-but-still-get-message-from-the-channel-tp27390.html
> Sent from the RabbitMQ mailing list archive at Nabble.com.
> _______________________________________________
> rabbitmq-discuss mailing list
> rabbitmq-discuss at lists.rabbitmq.com
> https://lists.rabbitmq.com/cgi-bin/mailman/listinfo/rabbitmq-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rabbitmq.com/pipermail/rabbitmq-discuss/attachments/20130614/b1899e13/attachment.htm>

More information about the rabbitmq-discuss mailing list