[rabbitmq-discuss] RabbitMQ - Not able to get sets of messages in the same order
Oleg Zhurakousky
ozhurakousky at vmware.com
Thu Jun 10 15:38:31 BST 2010
Not sure about C# API, and how you are building the next set of messages, but here is what I belive is happening.
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.
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.
Oleg
On Jun 10, 2010, at 10:24 AM, Srijanani Srinivasan wrote:
Hi,
I am using Rabbit MQ in C#. This is my scenario
1. A separate process publishes messages to the queue
2. Client has to read set of N messages from queue
3. Process the N messages
4. Acknowledge the N messages
5. Repeat steps 2 to 4 continuously to process all sets of messages
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.
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.
Below is the sample code:
while (true)
{
using (IModel getChannel = MQConnection.CreateModel())
{
// Create a consumer
QueueingBasicConsumer consumer = CreateQueueConsumer(getChannel, exchangeName, queueName);
int numberOfMessages = 100;
// Next Recieve
List<object> msgSet = GetNextSetOfMessages(consumer, getChannel, exchangeName, queueName, numberOfMessages, out finalDeliverytag);
// Do some processing
//Acknowledge finished messages by passing in the delivery tag.
// calls the method BasicAck with multiple param=true
if (finalDeliverytag > 0)
AckFinishedMessages(exchangeName, queueName, finalDeliverytag, getChannel);
if (finalDeliverytag == 0)
break;
}
}
Thanks for your help in advance!
Srijanani
<ATT00001..txt>
More information about the rabbitmq-discuss
mailing list