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 internal metadata fields for tracking ACKs and NACKs #24

Closed
lucasoares opened this issue Jun 27, 2023 · 3 comments · Fixed by #35
Closed

Add internal metadata fields for tracking ACKs and NACKs #24

lucasoares opened this issue Jun 27, 2023 · 3 comments · Fixed by #35
Labels
enhancement New feature or request help wanted Extra attention is needed proposal

Comments

@lucasoares
Copy link
Member

lucasoares commented Jun 27, 2023

Description

During a conversation with a colleague we discussed the need for some internal metadata fields to track ACKs (acknowledgments) and NACKs (negative acknowledgments) in Deckard. This issue proposes adding these fields to the metadata map of our messages.

Background

We were exploring the best approach to limit message retries (using NACK + LockMs) to a maximum of N attempts. The two options we considered were by using metadata or breakpoint field, which we were uncertain about its usage.

After discussing the matter, it became clear that for now the breakpoint field would serve as a suitable workaround, because the metadata field shuold not be used since it is not updated in NACKs or ACKs.

The "breakpoint" field is commonly used when a message is used to process a large number of elements, enabling the worker applications to track the progress and resume from where it left off. For example, if we have a social media page with 10,000 posts and need to process them in batches of 10, the "breakpoint" field allows the application to store the last processed position, ensuring it can continue from there in subsequent iterations on different workers.

Proposition

It would be beneficial to include some standard metadata fields in Deckard's pull responses. These fields would provide information on the number of ACKs/NACKs a message has received and the consecutive number of ACKs/NACKs. This information could be useful in the case described in this issue. It also would be useful, for example, in dynamically adjusting the time lock for a message based on the number of consecutive NACKs. All this controlled by the client application, which would be good to increase Deckard's ability to help users in different use cases without relying on some additional database.

The proposed metadata fields to be added are as follows:

{
 "_deckard.total_nacks" : "0",
 "_deckard.total_acks" : "321",
 "_deckard.consecutive_acks" : "12",
 "_deckard.consecutive_nacks" : "0"
}

Where all our internal metadata would be prefixed by _deckard to allow users distinguish between their own metadata.

We could add helpers for each client to get these numbers, since the metadata field is a map[string]string and I don't like adding each field individually in our message's struct. Any suggestion?

@lucasoares lucasoares added enhancement New feature or request help wanted Extra attention is needed proposal labels Jun 27, 2023
@lucasoares
Copy link
Member Author

lucasoares commented Jun 28, 2023

Maybe will be better adding a new field on the message struct called diagnostic or something like that, where we can put diagnostic information using either a structured message.

@cezar-tech
Copy link
Contributor

cezar-tech commented Jun 28, 2023

I think this is an awsome idea,

Recently @lucasoares has told me of an "eternal" message in our private enterprise, this is something that could also have helped me out. We can track down useless/broken elements that for some reason we can't work with and can just discard them with a removal_ack.

Can further lead down the road to even some sort of deadlettering architecture... who knows.

Since the best every event sourcing system of the galaxy (google pubsub) also delivers this so called diagnostic fields so I would say lets just mirror what works and this is pretty much it.

I back up this idea.

@lucasoares
Copy link
Member Author

I will add a new message inside all messas named "Diagnostic" and concentrate this kind of field inside it.

lucasoares added a commit that referenced this issue Jul 4, 2023
This commit adds a new field called `diagnostics` to the message.

The  `diagnostics` field contains the following fields:

- `acks` - to track the number of times the message was acknowledge
since its creation
- `nacks` - to track the number of times the message was
(not)acknowledge since its creation
- `consecutive_acks` - to track the number of times the message was
acknowledge since the last `NACK` signal
- `consecutive_nacks` - to track the number of times the message was
(not)acknowledge since the last `ACK` signal
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed proposal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants