Skip to content
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

Change message acknowledgement #317

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

sfendourakis
Copy link

This proposed solution addresses an issue encountered when attempting to utilize acknowledgment functionality.

Currently, the Receiver module contains two types of messages: AckableMessage originating from the broker, which includes an ack method to be executed upon task completion for acknowledging the message, and TaskiqMessage containing execution information passed to the run_task method responsible for task execution.

The challenge arises when a task encounters an exception, as there is presently no mechanism to modify the behavior of the ack method, resulting in automatic acknowledgment of the message. To mitigate this, we have introduced the passing of the ack method within the TaskiqMessage. This grants access to the ack method within the run_task context, enabling us to utilize a TaskiqMiddleware.on_error method. This method accepts the TaskiqMessage and adjusts the behavior of the ack method according to the desired logic in the event of a task failure.

Returning to the Receiver, the updated ack method will now be executed, resolving the issue of unintended acknowledgments for failed tasks.

While this solution addresses the immediate challenge, it's important to recognize that there may be alternative approaches. I welcome any feedback, suggestions, or alternative solutions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant