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

Ability to retry a message with custom exceptions #196

Open
EmilioCarrion opened this issue Feb 19, 2021 · 0 comments
Open

Ability to retry a message with custom exceptions #196

EmilioCarrion opened this issue Feb 19, 2021 · 0 comments

Comments

@EmilioCarrion
Copy link
Contributor

EmilioCarrion commented Feb 19, 2021

It would be useful to explicitly retry a message without the need of raising an exception. We currently have this behaviour:

try:
    res = self._subscription(data, **dict(message.attributes))
except Exception as e:
    run_middleware_hook(
        "post_process_message_failure",
        self._subscription,
        e,
        start_time,
        message,
    )
else:
    message.ack()
    run_middleware_hook(
        "post_process_message_success",
        self._subscription,
        start_time,
        message,
    )
    return res
finally:
    run_middleware_hook("post_process_message")

When the message is acked only when an exception is not raised. As commented in #80

It would be useful to be able to ack or retry the message explicitly using custom exceptions, per example:

raise Retry() (that would do nothing or a nack, this is discussed in the referenced issue)
raise Discard() (that would execute a message.ack())
@EmilioCarrion EmilioCarrion changed the title Ability to fail a message without raising an exception Ability to retry a message with custom exceptions Feb 19, 2021
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

No branches or pull requests

1 participant