-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Host.RabbitMQ] Automatically ack messages #214
Comments
So if I understand, you'd like to Ack the message right away upon arrival (before even processing starts in case the service process dies)? This will lead to at-most-once delivery guarantees. There is no direct way to make it happen nowadays, there is something similar that lets the user decide if to Ack or Nack in case of an error (see here). What I could propose is to 1) add a custom interceptor and 2) a way to Ack imperatively in that interceptor before message processing. The 2) will require a new feature which I could add here quite soon. The interceptor example is below: public class AckConsumerInterceptor<TMessage> : IConsumerInterceptor<TMessage>
{
public async Task<object> OnHandle(TMessage message, Func<Task<object>> next, IConsumerContext context)
{
context.Ack(); // ack before message processing starts (at-most-once)
return await next(); // process the message
}
} Let me know if that works. |
Thank you, works |
Сall context.Ack() in consumer handler throws an error |
@robert94p as I wrote earlier |
@robert94p thinking about it some more:
That way we can avoid the interceptor altogether. Let me know what you think. |
it would be nice to have both ways: through settings automatically and through context.Ack |
Great, that's what I am working on now. |
hey @robert94p the feature is in preview as of version 2.3.0-rc1: https://www.nuget.org/packages/SlimMessageBus.Host.RabbitMQ More about the feature: You should be able to set the Let me know if any issues or suggestions. |
How to ack messages automatically? so that a message started for processing is not processed again when the service is restarted
The text was updated successfully, but these errors were encountered: