[rabbitmq-discuss] Sent and received message counts don't match

Matthias Radestock matthias at lshift.net
Sun Oct 5 17:58:50 BST 2008


Haldun Bayhantopcu wrote:
> There is a producer script which produces 1000 messages containing
> random phrases and sends them to a fanout exchange.[1] It prints the
> number of sent messages as 1000, which I think that 1000 messages
> delivered successfully to rabbitmq.
> There are two consumer scripts[2,3] The first one just tries to
> get messages one by one with channel.basic_get(queue_name) resulting
> saying that it gets 998 messages. The second one uses a callback
> technique which I copied from the demo code. It prints ~500
> messages to the screen and seems to be stalled. And for one
> reason that I don't understand yet, the second consumer script
> fetches messages very fast than the first one.

Are you starting the consumer programs *after* the producer? If so then 
any messages published before the consumer programs create & bind their 
queues will be lost since the 'myfan' exchange has no place to route 
them to.

Also, the producer does not close the connection properly with 
conn.close. This too may result in messages getting dropped.

As for the comparative speed of the two consumer scripts - basic.consume 
is a more efficient way of consuming messages than basic.get, since the 
latter retrieves messages one at a time.



More information about the rabbitmq-discuss mailing list