apache / apache/pulsar-client-go

[Question] Semantics behind MaxDeliveries property

Open
#501 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
745
Forks
389
Avg merge
3d 20h
Merged PRs (30d)
3

Description

What is the meaning of `MaxDeliveries` property in `DLQPolicy`, should it equal to total deliveries including original attempt or should it equal to desired number of retries?

PIP document https://github.com/apache/pulsar/wiki/PIP-58-%3A-Support-Consumers--Set-Custom-Retry-Delay and Java client implementation define it like this:

`/**
* Maximum number of times that a message will be redelivered before
being sent to the dead letter queue.
*/
private int maxRedeliverCount;`

However, Go client implementation defines it like this:

`// Maximum number of times that a message will be delivered before being sent to the dead letter queue.
MaxDeliveries uint32`

To better understand meaning behind I also checked how those values used in tests. It seems there are actually two a bit different contexts when redelivery happens in Pulsar:
1. When client Nack the message or Ack timeout.
2. When client uses `reconsumeLater` api.

**Java client tests**
_Test for Nack_
https://github.com/apache/pulsar/blob/6704f12104219611164aa2bb5bbdfc929613f1bf/pulsar-broker/src/test/java/org/apache/pulsar/client/api/DeadLetterTopicTest.java#L101
Here we can see that meaning is really redelivery, we expect to get redelivery+1 messages, so redelivery count plus original attempt.
_Test for reconsumeLater_
https://github.com/apache/pulsar/blob/6704f12104219611164aa2bb5bbdfc929613f1bf/pulsar-broker/src/test/java/org/apache/pulsar/client/api/RetryTopicTest.java#L90
Same meaning, we expect to get redelivery+1 messages.

**Go client tests**
_Test for reconsumeLater_
https://github.com/apache/pulsar-client-go/blob/5fb7f55939e6f4ec28126339b22a6b4018c0f2fa/pulsar/consumer_test.go#L1194
Same expectations. So at this point I started to think that it is just bad naming in Go client, since `MaxDeliveries` value is used to provide max redeliveries actually. But
_Test for Nack_
https://github.com/apache/pulsar-client-go/blob/5fb7f55939e6f4ec28126339b22a6b4018c0f2fa/pulsar/consumer_test.go#L981
The meaning of value here is total deliveries. And this is the point where I am totally confused. How this test even passes in Go? It differs from corresponding Java `Nack` test expectations.

Contributor guide

Open the contributing guide

Research direction

Compare the Go client tests in pulsar/consumer_test.go with the linked Java DeadLetterTopicTest.java and RetryTopicTest.java cases, then trace how DLQPolicy.MaxDeliveries is interpreted in the Go client. Determine whether the differing Nack behavior is intentional or inconsistent; done means the semantics are documented and the affected implementation or tests agree.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, java
Domain
backend-api-design, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.