Thanks for your response. What you said makes sense. When the messages that have not been acknowledged are put back to the queue, then the�other�messages added in the meantime should be the ones to be de-queued first right in the FIFO manner? But like you said, i guess thats not�how�it works.<div>
<br></div><div>The same problem occurs, when I get a set of messages and don&#39;t acknowledge them and close the channel (in the event of any exceptions). When we get the messages, they do not come in the correct order.</div>
<div><br></div><div>I guess, if i want to get sets of messages instead of one at a time, I must try to use the same channel. Is that right?</div><div><br><div class="gmail_quote">On Thu, Jun 10, 2010 at 9:38 AM, Oleg Zhurakousky <span dir="ltr">&lt;<a href="mailto:ozhurakousky@vmware.com">ozhurakousky@vmware.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Not sure about C# API, and how you are building the next set of messages, but here is what I belive is happening.<br>
<br>
Channel prefetch messages. That is different then invoking a consumer. THis means that you might have 1000 prefetched messages in your channel, while you are still processing 21st message. Whatever you un-acknowledge is put back into the queue once the channel is closed. AMQO does not define an ordering of messages for re-queueing.<br>

One way to leverage this scenario is to set prefetchCount to 1. This way there will never me more then one prefetched messages in your channel.<br>
<br>
Oleg<br>
<div><div></div><div class="h5"><br>
On Jun 10, 2010, at 10:24 AM, Srijanani Srinivasan wrote:<br>
<br>
<br>
Hi,<br>
<br>
I am using Rabbit MQ in C#. This is my scenario<br>
1. � � � � � � � A separate process publishes messages to the queue<br>
2. � � � � � � � Client has to read set of N messages from queue<br>
3. � � � � � � � Process the N messages<br>
4. � � � � � � � Acknowledge the N messages<br>
5. � � � � � � � Repeat steps 2 to 4 continuously to process all sets of messages<br>
Under the same channel, I receive the messages and then process them and then acknowledge them. The server process keeps publishing messages. The problem I am facing is, when I try to get next set of messages, they do not come in the same order as it was published by the publishing process. The messages come in a random order. Only the first set of messages comes in the correct order.<br>

<br>
Does any one what is going wrong here? Is creating a new channel to access the next set of messages not right? Or is there a problem caused because of acknowledging multiple messages? Please help me understand why this does not work correctly.<br>

<br>
Below is the sample code:<br>
while (true)<br>
 � � � � � �{<br>
 � � � � � � � �using (IModel getChannel = MQConnection.CreateModel())<br>
 � � � � � � � �{<br>
 � � � � � � � � � �// Create a consumer<br>
 � � � � � � � � � �QueueingBasicConsumer consumer = CreateQueueConsumer(getChannel, exchangeName, queueName);<br>
 � � � � � � � � � �int numberOfMessages = 100;<br>
 � � � � � � � � � �// Next Recieve<br>
 � � � � � � � � � �List&lt;object&gt; msgSet = GetNextSetOfMessages(consumer, getChannel, exchangeName, queueName, numberOfMessages, � � � � � � out finalDeliverytag);<br>
 � � � � � � � � � �// Do some processing<br>
 � � � � � � � � � �//Acknowledge finished messages by passing in the delivery tag.<br>
 � � � � � � � � � �// calls the method BasicAck with multiple param=true<br>
 � � � � � � � � � �if (finalDeliverytag &gt; 0)<br>
 � � � � � � � � � � � �AckFinishedMessages(exchangeName, queueName, finalDeliverytag, getChannel);<br>
 � � � � � � � � � �if (finalDeliverytag == 0)<br>
 � � � � � � � � � � � �break;<br>
 � � � � � � � �}<br>
 � � � � � �}<br>
<br>
Thanks for your help in advance!<br>
Srijanani<br>
<br>
</div></div>&lt;ATT00001..txt&gt;<br>
<br>
</blockquote></div><br></div>