BewareMyPower opened a new pull request, #19158:
URL: https://github.com/apache/pulsar/pull/19158

   Master Issue: https://github.com/apache/pulsar/issues/18616
   
   ### Motivation
   
   Introduce `TopicMessageId` to support getting the owner topic of a 
`MessageId`. When a `MessageId` is retrieved from a received message, the owner 
topic will be correctly set by the client library. When it's returned by 
`Producer#send`, this PR provides a `TopicMessageId#create` method to configure 
the owner topic.
   
   `acknowledge` APIs are affected only for the error cases: when a `MessageId` 
other than a `TopicMessageId` is accepted on a multi-topics consumer, 
`PulsarClientException.NotAllowedException` will be thrown.
   
   The semantic of the `seek(MessageId)` API is changed. Now if a 
`TopicMessageId` is accepted on a multi-topics consumer, the seek behavior will 
happen on the internal consumer of the owner topic.
   
   ### Modifications
   
   - Add the `TopicMessageId` interface.
   - In `MultiTopicsConsumerImpl#doAcknowledge`, complete the future with 
`NotAllowedException` if the argument is not a `TopicMessageId`.
   - In `MultiTopicsConsumerImpl#seekAsync`, when the argument is a 
`TopicMessageId`, find the internal consumer according to the owner topic and 
pass the argument to it if it exists.
   - In `ConsumerImpl#seekAsync`, get the inner message ID of the 
`TopicMessageId` so that now a single-topic consumer can also accept a 
`TopicMessageId` to seek.
   
   Besides the main modifications above, this patch does some refactorings to 
avoid direct access to `TopicMessageIdImpl`:
   - Deprecated `getTopicName` method by trimming the partition suffix of the 
owner topic in `getOriginTopicNameStr`.
   - Deprecated `getTopicPartitionName` by `getOwnerTopic`.
   - `getInnerMessageId` cannot be deprecated because we still need to convert 
`TopicMessageId` to `MessageIdImpl` in many cases (because we cannot get the 
fields like ledger id). Instead of deprecating it, use 
`MessageIdImpl.convertToMessageIdImpl` to replace it.
   - In `convertToMessageIdImpl`, for a customized `TopicMessageId` 
implementation, use serialization and deserialization to get the 
`MessageIdImpl` object.
   
   ### Verifications
   
   Add the following tests to `MultiTopicsConsumerTest`:
   - `testAcknowledgeWrongMessageId`: verify the correct exceptions are thrown 
in `acknowledge` APIs
   - `testSeekCustomTopicMessageId`: verify the new seek semantics for a 
`TopicMessageId`, including the existing `TopicMessageIdImpl` and the 
customized implementation by `TopicMessageId#create`
   
   ### TODO
   - Add a standard SerDes class for `TopicMessageId`
   - Apply `TopicMessageId` into `getLastMessageId` related APIs.
   - Deprecate the `getInnerMessageId` after PIP-229 is approved.
   
   ### Does this pull request potentially affect one of the following parts:
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   *If the box was checked, please highlight the changes*
   
   - [ ] Dependencies (add or upgrade a dependency)
   - [x] 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
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. Please attach the local 
preview screenshots (run `sh start.sh` at `pulsar/site2/website`) to your PR 
description, or else your PR might not get merged. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: https://github.com/BewareMyPower/pulsar/pull/17


-- 
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]

Reply via email to