[rabbitmq-discuss] lost messages (.NET)

ivan.lysov ivan.lysov at gmail.com
Wed Jun 27 18:26:41 BST 2012


Hi, i'm new to RabbitMQ, currently trying out some real-world cases. 
The case is:
1) Producer publishes about 10 messages per second.
2) First consumer starts consuming the messages and after some consuming
hangs for a while (Console.ReadLine()) 
3) While the first consumer is hanging second consumer starts to consume the
messages from the same queue (not immidiatly, after n seconds)
4) I kill first consumer, watch logs and what i see is there are some
messages that weren't acknowledged but deleted from the queue and i never
see them.

Here is the code (first consumer):

using (IModel model = connection.CreateModel())
                {
                    var subscription = new Subscription(model, "MyQueue",
false);
                    var i = 0;

                    using (StreamWriter writer =
File.AppendText("C:/RabbitMQlog.txt"))
                    {

                       
writer.WriteLine("============================================");
                        
                        while (true)
                        {

                            i++;
                            BasicDeliverEventArgs basicDeliverEventArgs =
subscription.Next();

                            string messageContent =
Encoding.UTF8.GetString(basicDeliverEventArgs.Body);

                            writer.WriteLine(messageContent);
                            writer.Flush();
                            Console.WriteLine(messageContent);

                            subscription.Ack(basicDeliverEventArgs );

                            if (i == 100)
                                Console.ReadLine();
                        }
                    }
                }

Could anyone help me with this issue?


--
View this message in context: http://rabbitmq.1065348.n5.nabble.com/lost-messages-NET-tp20402.html
Sent from the RabbitMQ mailing list archive at Nabble.com.


More information about the rabbitmq-discuss mailing list