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
Bug Report - Lack of Graceful Shutdown in Message Updates Handling #1321
Comments
I wouldn't say that this is a bug, but a specific behaviour desired by some people. I could implement an additional option to do that, but it won't be 100% reliable and have it's own can of worms. E.g. how do you think we should handle cancellation in this case since the original token is cancelled? I see three options how to commit the last offset:
To me the first two are horrible since they introduce not obvious lifetimes and cancellation mechanisms and only the third one seems the most sane. In the end, there is no easy solution that is ideal and satisfy everyone. |
@tuscen, I suggest the following solution: Firstly, we could introduce a check for the cancellation token within each iteration of the foreach-loop. And if a cancellation is requested, break out of the loop, ensuring that any remaining updates are not handled. Secondly, upon cancellation, send a Suggested changes in code:
|
@Palindromer That's what I wrote earlier - your suggested code does not handle cancellation at all |
@tuscen Could you please explain more why do you think cancellation is not adequately handled by the suggested code? |
The current implementation lacks a graceful shutdown mechanism when handling message updates due to the absence of storing the offset for processed messages during shutdown.
If a
cancellationToken
is requested, message updates are processed, but themessageOffset
does not shift. This is because the offset is committed through sending aGetUpdatesRequest
. Consequently, after a shutdown, all messages from the last batch are reprocessed!Steps to reproduce
CTRL+C
) while processing a batch of messages.Expected behavior
After the app termination request, the offset of processed messages is shifted. So that after restart the app, these messages won't be processed again.
Actual behavior
After the app termination request, all messages in the last batch are handled, but the offset is not shifted for them. As a result, upon restarting the application, this batch will be processed again!
Environment
NuGet Package Version: 19.0.0
The text was updated successfully, but these errors were encountered: