<div class="gmail_quote"><p style="margin-top:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;line-height:13.5pt;vertical-align:baseline"><span style="font-size:10.5pt;font-family:Arial;color:black">Hi,</span></p>


<p style="margin-top:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;line-height:13.5pt;vertical-align:baseline"><span style="font-size:10.5pt;font-family:Arial;color:black">I am using Rabbit MQ in C#. This is my scenario</span></p>


<p class="MsoNormal" style="margin-left:22.5pt;line-height:13.5pt;vertical-align:baseline"><span style="font-size:10.5pt;font-family:Arial;color:black"><span>1.<span style="font:7.0pt &quot;Times New Roman&quot;">              
</span></span></span><span style="font-size:10.5pt;font-family:Arial;color:black">A separate process publishes messages to the queue</span></p>

<p class="MsoNormal" style="margin-left:22.5pt;line-height:13.5pt;vertical-align:baseline"><span style="font-size:10.5pt;font-family:Arial;color:black"><span>2.<span style="font:7.0pt &quot;Times New Roman&quot;">              
</span></span></span><span style="font-size:10.5pt;font-family:Arial;color:black">Client has to read set of N messages from queue</span></p>

<p class="MsoNormal" style="margin-left:22.5pt;line-height:13.5pt;vertical-align:baseline"><span style="font-size:10.5pt;font-family:Arial;color:black"><span>3.<span style="font:7.0pt &quot;Times New Roman&quot;">              
</span></span></span><span style="font-size:10.5pt;font-family:Arial;color:black">Process the N messages</span></p>

<p class="MsoNormal" style="margin-left:22.5pt;line-height:13.5pt;vertical-align:baseline"><span style="font-size:10.5pt;font-family:Arial;color:black"><span>4.<span style="font:7.0pt &quot;Times New Roman&quot;">              
</span></span></span><span style="font-size:10.5pt;font-family:Arial;color:black">Acknowledge the N messages</span></p>

<p class="MsoNormal" style="margin-left:22.5pt;line-height:13.5pt;vertical-align:baseline;border-style:initial;border-color:initial;word-wrap:break-word;background-repeat:initial initial"><span style="font-size:10.5pt;font-family:Arial;color:black"><span>5.<span style="font:7.0pt &quot;Times New Roman&quot;">              
</span></span></span><span style="font-size:10.5pt;font-family:Arial;color:black">Repeat steps 2 to 4 continuously to process all sets of messages</span></p>

<p class="MsoNormal" style="margin-left:4.5pt;line-height:13.5pt;vertical-align:baseline;border-style:initial;border-color:initial;word-wrap:break-word;background-repeat:initial initial"><span style="font-size:10.5pt;font-family:Arial;color:black">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.</span></p>

<p style="margin-top:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;line-height:13.5pt;vertical-align:baseline;border-style:initial;border-color:initial;word-wrap:break-word;background-repeat:initial initial">
<span style="font-size:10.5pt;font-family:Arial;color:black">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. </span></p>

<p style="margin-top:0in;margin-right:0in;margin-bottom:12.0pt;margin-left:0in;line-height:13.5pt;vertical-align:baseline"><span style="font-size:10.5pt;font-family:Arial;color:black">Below is the sample code:</span></p>


<p class="MsoNormal" style="text-indent:.5in;text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;;color:blue"></span>while<span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"> (<span style="color:blue">true</span>)</span></p>


<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>            </span>{</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                </span><span style="color:blue">using</span>
(<span style="color:#2B91AF">IModel</span> getChannel =
MQConnection.CreateModel())</span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                </span>{</span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                    </span><span style="color:green">//
Create a consumer</span></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                    </span><span style="color:#2B91AF">QueueingBasicConsumer</span>
consumer = CreateQueueConsumer(getChannel, exchangeName, queueName); </span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                    </span><span style="color:blue">int</span>
numberOfMessages = 100;</span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                    </span><span style="color:green">//
Next Recieve</span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span style="color:green"><span style="color:rgb(0, 0, 0)"><span>                    </span><span style="color:#2B91AF">List</span>&lt;<span style="color:blue">object</span>&gt; msgSet = GetNextSetOfMessages(consumer,
getChannel, exchangeName, queueName, numberOfMessages,             <span style="color:blue">out</span>
finalDeliverytag); </span></span></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                    </span><span style="color:green">//
Do some processing </span></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                    </span><span style="color:green">//Acknowledge
finished messages by passing in the delivery tag.</span></span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span style="color:green"><span style="color:rgb(0, 0, 0)"><span>        </span><span>            </span><span style="color:green">// calls
the method BasicAck with multiple param=true</span></span></span></span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                    </span><span style="color:blue">if</span>
(finalDeliverytag &gt; 0)</span></p><p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                        </span>AckFinishedMessages(exchangeName, queueName, finalDeliverytag,
getChannel);</span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-family:&#39;Courier New&#39;;font-size:13px"><span>                    </span><span style="color:blue">if</span>
(finalDeliverytag == 0)</span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                        </span><span style="color:blue">break</span>;</span></p>

<p class="MsoNormal" style="text-autospace:none"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>                </span>}</span></p>


<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"><span>            </span>}</span></p>

<p class="MsoNormal"><span style="font-size:10.0pt;font-family:&quot;Courier New&quot;"> </span></p>

<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Arial">Thanks for your help in advance! </span></p>

<p class="MsoNormal"><span style="font-size:10.5pt;font-family:Arial">Srijanani</span><span style="font-size:10.5pt;font-family:Arial"></span></p>
</div><br>