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

[improve][pip] PIP-372: Allow consumers to terminally NACK a message, bypassing retries and routing directly to the DLQ #23133

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

jcass8695
Copy link

@jcass8695 jcass8695 commented Aug 7, 2024

PIP: 372

Motivation

If a consumer consumes a message and fails during the processing of that message in a terminal way, we as the client in
certain scenarios may not want to retry that message later, we may want to send it directly to the DLQ. Currently, if
the client wanted a persistent record of the message, they would have to do one of:

  1. NACK the message and retry it up to the configured max retries, when it would then land in the DLQ.
  2. ACK the message and explicity produce it to the DLQ.
  3. ACK the message and persist it in some other system, e.g. a database table, a log file.

I propose adding an interface that allows a consumer to terminally NACK a message, sending it directly to the DLQ instead of retrying.

Modifications

No modification yet.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage.

  • Documentation only

Does this pull request potentially affect one of the following parts:

  • Dependencies (add or upgrade a dependency)
  • The public API
  • The schema
  • The default values of configurations
  • The threading model
  • The binary protocol
  • The REST endpoints
  • The admin CLI options
  • The metrics
  • Anything that affects deployment

Documentation

  • doc
  • doc-required
  • doc-not-needed
  • doc-complete

Matching PR in forked repository

PR in forked repository:

@github-actions github-actions bot added the PIP label Aug 7, 2024
Copy link

github-actions bot commented Aug 7, 2024

@jcass8695 Please add the following content to your PR description and select a checkbox:

- [ ] `doc` <!-- Your PR contains doc changes -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->

@jcass8695 jcass8695 changed the title [improve][client] PIP-367: Allow consumers to terminally NACK a message, bypassing retries and routing directly to the DLQ [improve][pip] PIP-367: Allow consumers to terminally NACK a message, bypassing retries and routing directly to the DLQ Aug 7, 2024
@github-actions github-actions bot added doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. and removed doc-label-missing labels Aug 7, 2024
@crossoverJie
Copy link
Member

@jcass8695 This is a great feature. I have added the relevant methods for Java.

BTW, the PIP number is conflicting with #23061.

pip/pip-367.md Outdated
### Metrics

If the client would like to track the number of calls to the `Term` method, we could add a new metric
`pulsar_client_consumer_terms`. This metric should in theory track exactly with the
Copy link
Member

Choose a reason for hiding this comment

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

pulsar_client_consumer_message_terms
It is recommended to keep the naming conventions consistent.

consumerDlqMessagesCounter = ip.newCounter("pulsar.client.consumer.message.dlq", Unit.Messages,
"The number of messages sent to DLQ", topic, attrs);

Copy link
Author

@jcass8695 jcass8695 Aug 8, 2024

Choose a reason for hiding this comment

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

They are all defined with underscores in the Go client library.

https://github.com/apache/pulsar-client-go/blob/master/pulsar/internal/metrics.go#L266-L270

Copy link
Member

Choose a reason for hiding this comment

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

The Java client is currently using OpenTelemetry's naming conventions. I suggest aligning it with the existing naming style.

Copy link
Author

Choose a reason for hiding this comment

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

I think that moving the Go client to be OTel compliant is outside the scope of this change. I think I would rather the Go client be consistent with itself. Changing all of the metrics to be OTel compliant can be done in a single non-backwards compatible change.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, I meant that the Java client should follow the current naming conventions. It would be best to also add a description for Java metrics.

@jcass8695
Copy link
Author

jcass8695 commented Aug 8, 2024

@jcass8695 This is a great feature. I have added the relevant methods for Java.

BTW, the PIP number is conflicting with #23061.

  • @crossoverJie I'll change the PIP number.
  • I sent an email to [email protected] but it seems like there hasn't been any discussion thread created that I can see on the mailing lists forum - does it need to be manually approved or something?
  • Do you have a link to those methods in the Java library? I will try to make them the same so that there's parity.

@crossoverJie
Copy link
Member

  • I sent an email to [email protected] but it seems like there hasn't been any discussion thread created that I can see on the mailing lists forum - does it need to be manually approved or something?

I didn't see the related discussion on the mailing list. Please double-check if the email has been sent.

  • Do you have a link to those methods in the Java library? I will try to make them the same so that there's parity.

https://github.com/apache/pulsar/blob/master/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Consumer.java

@jcass8695
Copy link
Author

  • I sent an email to [email protected] but it seems like there hasn't been any discussion thread created that I can see on the mailing lists forum - does it need to be manually approved or something?

I didn't see the related discussion on the mailing list. Please double-check if the email has been sent.

  • Do you have a link to those methods in the Java library? I will try to make them the same so that there's parity.

https://github.com/apache/pulsar/blob/master/pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Consumer.java

I've resent my email now, with the updated PIP number.

@jcass8695 jcass8695 changed the title [improve][pip] PIP-367: Allow consumers to terminally NACK a message, bypassing retries and routing directly to the DLQ [improve][pip] PIP-372: Allow consumers to terminally NACK a message, bypassing retries and routing directly to the DLQ Aug 9, 2024
@jcass8695
Copy link
Author

@crossoverJie still no thread on the mailing list 😞

@jcass8695
Copy link
Author

@crossoverJie still no thread on the mailing list 😞

Below is the email that I've sent. Am I doing something wrong? This feels like it should be the easy step...

image

@crossoverJie
Copy link
Member

image

@jcass8695 However, I did not see the email you send on the mailing list🤔.

```

```java
public interface Consumer<T> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move the definition of the new API into the section Public API


# Links

* Mailing List discussion thread:
Copy link
Contributor

Choose a reason for hiding this comment

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

Please send an email for a discussion of this PIP

Copy link
Author

Choose a reason for hiding this comment

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

My email is not making it to the mailing lists. Please see above comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc Your PR contains doc changes, no matter whether the changes are in markdown or code files. PIP
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants