[rabbitmq-discuss] py-amqplib status messages

Dmitriy Samovskiy dmitriy.samovskiy at cohesiveft.com
Mon Nov 24 16:54:45 GMT 2008


Hi Matthias,

Matthias Radestock wrote:
>>
>> def main():
>>   conn = A.Connection('localhost', userid='tsuraan', password='tsuraan')
>>   chan = conn.channel()
>>
>>   for i in range(1000):
>>     m = A.Message(str(i), delivery_mode=2)
>>     chan.basic_publish(m, 'rawmsg', 'standard', mandatory=True, immediate=False)
>>
>> if __name__ == "__main__":
>>   main()
> 
> The above program exits without closing the channel or connection 
> properly first. As a result, any messages that are "in flight" will be lost.
> 

How do you define "messages in flight" in this scenario?

I played with this code and tcpdump, and discovered that there could be a single TCP 
packet (ack'ed by broker's network stack) with multiple basic.publish methods inside, and 
some of those methods were processed by rabbit, and some were not. Furthermore, there 
could be more TCP packets after this one that also were TCP-ack'ed but were not processed 
by broker.

In rabbit_reader.erl, in mainloop function, I see this:

{inet_async, Sock, Ref, {error, closed}} ->
    if State#v1.connection_state =:= closed ->
       State;
    true ->
       throw(connection_closed_abruptly)
    end;


Maybe before raising an exception, broker could look in its incoming buffer and see if 
there is more data there? It can maybe disregard all methods that require a response 
(because a TCP connection is no longer established at this point), but if it finds 
basic.publish or other methods that do not require response - maybe it could process them?

Is it a fair assumption that if a TCP packet was ack'ed, it means its contents reached the 
broker and would be processed eventually?


- Dmitriy




More information about the rabbitmq-discuss mailing list