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

[feat] Support batch index acknowledgment #151

Merged

Conversation

BewareMyPower
Copy link
Contributor

Fixes #87

Modifications

  • Add an consumer configuration setBatchIndexAckEnabled to enable the batch index ACK. When it's enabled, passing the original MessageId instead of the MessageIdImpl that trunks the batch index to the ACK grouping tracker.
  • Since now a BatchedMessageIdImpl could be accepted in the ACK grouping tracker, fix the compare logic.
  • Support passing a BitSet in Commands::newAck and get the internal BitSet from MessageId in Commands::newMultiMessageAck.
  • Skip the acknowledged batch indexes when receiving batched messages in ConsumerImpl::receiveIndividualMessagesFromBatch.

Verifications

Modify BitSetTest.testSet to verify the BitSet::get method added in this commit.

Add AcknowledgeTest.testBatchIndexAck to test batch index ACK for all types of acknowledgment:

  • Individual ACK for a single message
  • Individual ACK for a list of messages
  • Cumulative ACK

Add AcknowledgeTest.testMixedCumulativeAck to test the new compare logic between BatchedMessageIdImpl and MessageIdImpl works for cumulative ACK.

Documentation

  • doc-required
    (Your PR needs to update docs and you will update later)

  • doc-not-needed
    (Please explain why)

  • doc
    (Your PR contains doc changes)

  • doc-complete
    (Docs have been already added)

Fixes apache#87

### Modifications

- Add an consumer configuration `setBatchIndexAckEnabled` to enable the
  batch index ACK. When it's enabled, passing the original `MessageId`
  instead of the `MessageIdImpl` that trunks the batch index to the ACK
  grouping tracker.
- Since now a `BatchedMessageIdImpl` could be accepted in the ACK
  grouping tracker, fix the compare logic.
- Support passing a `BitSet` in `Commands::newAck` and get the internal
  `BitSet` from `MessageId` in `Commands::newMultiMessageAck`.
- Skip the acknowledged batch indexes when receiving batched messages in
  `ConsumerImpl::receiveIndividualMessagesFromBatch`.

### Verifications

Modify `BitSetTest.testSet` to verify the `BitSet::get` method added in
this commit.

Add `AcknowledgeTest.testBatchIndexAck` to test batch index ACK for all
types of acknowledgment:
- Individual ACK for a single message
- Individual ACK for a list of messages
- Cumulative ACK

Add `AcknowledgeTest.testMixedCumulativeAck` to test the new compare
logic between `BatchedMessageIdImpl` and `MessageIdImpl` works for
cumulative ACK.
@BewareMyPower BewareMyPower added the enhancement New feature or request label Dec 20, 2022
@BewareMyPower BewareMyPower added this to the 3.2.0 milestone Dec 20, 2022
@BewareMyPower BewareMyPower self-assigned this Dec 20, 2022
@BewareMyPower BewareMyPower changed the title Support batch index acknowledgment [feat] Support batch index acknowledgment Dec 21, 2022
@BewareMyPower
Copy link
Contributor Author

@merlimat @RobertIndie @Demogorgon314 Could you take a second look?

@BewareMyPower
Copy link
Contributor Author

@merlimat @RobertIndie @Demogorgon314 This PR has been pending for 3 weeks. Could any committer take a look?

@BewareMyPower BewareMyPower merged commit 06eab69 into apache:main Jan 17, 2023
BewareMyPower added a commit to BewareMyPower/pulsar-client-cpp that referenced this pull request Jan 17, 2023
### Motivation

Currently the main branch is broken by the concurrent merge of
apache#153 and
apache#151. It's because when
a batched message id is constructed from deserialization, there is no
`getBitSet` implementation of the internal acker.

### Modifications

Add a `bool` parameter to `MessageIdImpl::getBitSet` to indicate whether
the message ID is batched. The logic is similar with

https://github.com/apache/pulsar/blob/299bd70fdfa023768e94a8ee4347d39337b6cbd4/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java#L325-L327

and

https://github.com/apache/pulsar/blob/299bd70fdfa023768e94a8ee4347d39337b6cbd4/pulsar-client/src/main/java/org/apache/pulsar/client/impl/PersistentAcknowledgmentsGroupingTracker.java#L345-L347

Add a `testMessageIdFromBuild` to test the acknowledgment for a message
ID without an acker could succeed for a consumer that enables batch
index ACK.

### TODO

In future, apache/pulsar#19031 might be migrated
into the C++ client to fix the consumer that disables batch index ACK.
BewareMyPower added a commit to BewareMyPower/pulsar-client-cpp that referenced this pull request Jan 18, 2023
### Motivation

Currently the main branch is broken by the concurrent merge of
apache#153 and
apache#151.

### Modifications

Add a dummy `getBitSet` implementation to `BatchMessageAcker` and the
correct implementation for `BatchMessageAckerImpl`.
Demogorgon314 pushed a commit that referenced this pull request Jan 18, 2023
### Motivation

Currently the main branch is broken by the concurrent merge of
#153 and
#151.

### Modifications

Add a dummy `getBitSet` implementation to `BatchMessageAcker` and the
correct implementation for `BatchMessageAckerImpl`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[feature request] C++ and Python support batch index acknowledgment
3 participants