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

add explicit ack/nak for nats jetstream #1073

Conversation

stephen-totty-hpe
Copy link
Contributor

In some cases, it is necessary to control manual ACK/NCK based on the existance of errors. It is ok to ACK/NCK even if the message has already been committed. In that case, the ACK/NCK is short-circuited.

@stephen-totty-hpe stephen-totty-hpe requested a review from a team as a code owner July 9, 2024 14:29
// see: ManualAck() subscription option
// see: ConsumerConfig.AckPolicy
if err != nil {
_ = m.Msg.Nak()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does ignoring the return here potentially cause issues? Is the 'already ak'd' error the only kind of error that we can get from this operation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added code to handle expected error cases. In all other cases, will return error.

Signed-off-by: stephen-totty-hpe <stephen.totty@hpe.com>
// see: ManualAck() subscription option
// see: ConsumerConfig.AckPolicy
if err != nil {
errNak := m.Msg.Nak()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What are other errors that Ack and Nak can return? Can you please run a local dummy test with a real NATS backend and always return an error here so we understand how the system behaves end-to-end? IMHO it should be fine (warning logged), but want to make sure this doesn't lead to an endless invocation loop since with this change we're changing the behavior for users.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will close this PR if #1095 gets merged.

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.

4 participants