BewareMyPower opened a new pull request, #1301:
URL: https://github.com/apache/pulsar-client-go/pull/1301
### Motivation
For `Shared` and `Key_Shared` subscriptions, if some messages failed to
acknowledge, these messages would never be dispatched to the consumer until
restarted. If the number of unacknowledged messages reached the threshold, the
broker would never dispatch messages anymore. However, the consumer does not
have a chance to check which messages failed to acknowledged.
Even if this case was not hit, if the consumer restarted after consuming
many messages, the old unacknowledged messages would be delivered again, which
is very confusing and might affect the business logic.
Therefore, we can only enable `AckWithResponse` to know which messages
failed to acknowledge. Unfortunately, currently the Go SDK only supports
acknowledging single messages. It harms the performance significantly.
To solve this solution, this PR adds an API to acknowledge a list of
messages.
```golang
// AckIDList the consumption of a list of messages, identified by their
MessageIDs
// Returns a map of MessageID to error, the keys are the MessageIDs
that failed to be acknowledged
AckIDList([]MessageID) map[MessageID]error
```
Users can save the failed message IDs and add them again in the next
`AckIDList` call.
### Modifications
- Add an `AckIDList` API and reuse the logic of `ack_grouping_tracker.go` to
convert user provided message IDs to the message IDs in the ACK requests
- Add the request id to the ACK request in `internalAckList` and wait for
the response error via a error channel
- Add `TestAckIDList` to verify the case that a message ID list has message
IDs of non-batched messages, whole batched messages or partial batched messages
because the behaviors are different if the batch index ACK is enabled
- Add `TestMultiTopicAckIDList` to verify the multi-topics case, including
regex subscription.
### Does this pull request potentially affect one of the following parts:
*If `yes` was chosen, please highlight the changes*
- Dependencies (does it add or upgrade a dependency): (yes / no)
- The public API: (**yes**)
- The schema: (yes / no / don't know)
- The default values of configurations: (yes / no)
- The wire protocol: (yes / no)
### Documentation
- Does this pull request introduce a new feature? (**yes**)
- If yes, how is the feature documented? (not applicable / docs / GoDocs /
not documented)
- If a feature is not applicable for documentation, explain why?
- If a feature is not documented yet in this PR, please create a followup
issue for adding the documentation
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]