I'm developing an application for messaging using Rabbit MQ. I use explicit ACK:
model.BasicConsume(queueName,false, consumer);
and do ACK after processing message:
consumer.Received += (ch, ea) =>
{
try
{
var message = Encoding.UTF8.GetString(ea.Body);
Logger.Info($"DeliveryTag={ea.DeliveryTag}, message={message}");
((EventingBasicConsumer)ch).Model.BasicAck(ea.DeliveryTag, false);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
};
The problem is when there is an error of processing a message and Rabbit doesn't receive ACK, it returns the message to the queue in different order.
Fore example there are messages M1, M2, M3, M4.
If M2 was returned to queue, it will be M3, M4, M2.
Is there any way to keep the order of delivery?
P.S. I have only one consumer and RabbitMQ 3.6.6, but I still have problem of reordering.