-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Pubsub: How to flush unsent messages on program exit? #6883
Comments
A workaround is to use Seek and seek to the current timestamp. This way, messages that were published before this time are marked as acknowledged, and messages retained in the subscription that were published after this time are marked as unacknowledged. |
@plamut do you have any advice about this question? |
I'm not 100% sure if I understand the question correctly, but does "caching" refer to the batch settings used when publishing messages? E.g the If so, one way of forcing the publisher to actually send the messages to the server (e.g. on program exit) is to manually invoke the batch.commit() method. The publisher client internally stores message batches for each topic here, thus forcing a batch to commit messages early could be done with the following: topic_batch = publisher._batches.get(TOPIC_PATH)
if topic_batch is not None:
topic_batch.commit() (invoking @mckingho Does that answer your question? Or maybe what @anguillanneuf wrote earlier? If not and "caching configuration" refers to something else, we would need a bit more info. Looking forward to hearing again from you! |
@plamut: I think the user wants to have a method to ensure that all messages have successfully been sent... i.e. all futures have completed. |
We may need documentation (or a new method) for how to wait for shut down until all futures are complete. |
I have set caching configuration which may cache some messages and messages are not sent to pubsub yet. Is there a
flush
method when I want to exit the program.The text was updated successfully, but these errors were encountered: