pardahlman / RawRabbit

A modern .NET framework for communication over RabbitMq
MIT License
747 stars 144 forks source link

Lost Messages with Retry.In #294

Closed wh33ler closed 6 years ago

wh33ler commented 6 years ago

While testing some scenarios I had the following Issue with the 2.0.0-rc1 version:

            bus.SubscribeAsync<TCommand> (async (msg) => {
                try{
                    await handler.HandleAsync (msg); 
                    Console.WriteLine($"ACK"); 
                    return new Ack();                    
                }catch(Exception){                    
                    Console.WriteLine($"Retry"); 
                    return Retry.In(TimeSpan.FromSeconds(30));                    
                }
            }

the handler.HandleAsync method throws an instant Exception. The Console Logs the Retry Message for every Message sent ( 10 in a row ). But only around 4 to 9 Messages get really requeued in RabbitMQ.

Inserting an Thread.Sleep(200) before the Throw Exception will fix this issue. Looks like some race condition of some sort.

Any Ideas?

wh33ler commented 6 years ago

using Plugins = p => p.UseGlobalExecutionId() seems to fix that issue.

arrkaye commented 6 years ago

@pardahlman Hey mate, Is the GlobalExecutionId required for the retry functionality to work?