You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2023/01/09 04:28:28 UTC

[GitHub] [pulsar] BewareMyPower opened a new pull request, #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] codelipenghui commented on a diff in pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui commented on code in PR #19158:
URL: https://github.com/apache/pulsar/pull/19158#discussion_r1091356208


##########
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/MessageAcknowledger.java:
##########
@@ -49,6 +49,8 @@ public interface MessageAcknowledger {
      *
      * @throws PulsarClientException.AlreadyClosedException}
      *             if the consumer was already closed
+     * @throws PulsarClientException.NotAllowedException
+     *             if `messageId` is not a {@link TopicMessageId} when multiple topics are subscribed

Review Comment:
   Ok, got it.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on code in PR #19158:
URL: https://github.com/apache/pulsar/pull/19158#discussion_r1090413929


##########
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/MessageAcknowledger.java:
##########
@@ -49,6 +49,8 @@ public interface MessageAcknowledger {
      *
      * @throws PulsarClientException.AlreadyClosedException}
      *             if the consumer was already closed
+     * @throws PulsarClientException.NotAllowedException
+     *             if `messageId` is not a {@link TopicMessageId} when multiple topics are subscribed

Review Comment:
   > Does the TopicMessageId interface is intentionally exposed to users? 
   
   Yes. The new `getLastTopicMessageId` APIs will return `TopicMessageId` instances, they will be introduced in another PR, see the [original PIP issue](https://github.com/apache/pulsar/issues/18616).. And users can avoid touching the `pulsar-client` module (internal implementations) to get the topic name of a message ID.
   
   ```java
   if (msgId instanceof TopicMessageId) {
       multiTopicsConsumer.seek(msgId);
   } else {
       multiTopicsConsumer.seek(TopicMessageId.create(topic, msgId));
   }
   ```
   
   > Which one should be suggested in the future?
   
   `fromByteArrayWithTopic` should be deprecated. The `MessageId` that is not a `TopicMessageId` could be retrieved from other ways, not only the deserialization. But `fromByteArrayWithTopic` assumes it (e.g. a `MessageIdImpl`) was retrieved from deserialization.
   



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] codecov-commenter commented on pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #19158:
URL: https://github.com/apache/pulsar/pull/19158#issuecomment-1410072569

   # [Codecov](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#19158](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (51a375d) into [master](https://codecov.io/gh/apache/pulsar/commit/c17f355428e544c0d14fe24848bfb9fed5e3ef48?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (c17f355) will **decrease** coverage by `1.56%`.
   > The diff coverage is `60.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/pulsar/pull/19158/graphs/tree.svg?width=650&height=150&src=pr&token=acYqCpsK9J&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #19158      +/-   ##
   ============================================
   - Coverage     64.33%   62.78%   -1.56%     
   + Complexity    26041    25551     -490     
   ============================================
     Files          1818     1819       +1     
     Lines        133110   133134      +24     
     Branches      14644    14647       +3     
   ============================================
   - Hits          85641    83582    -2059     
   - Misses        39640    41841    +2201     
   + Partials       7829     7711     -118     
   ```
   
   | Flag | Coverage Δ | |
   |---|---|---|
   | inttests | `25.04% <21.40%> (+0.16%)` | :arrow_up: |
   | systests | `25.59% <14.03%> (+<0.01%)` | :arrow_up: |
   | unittests | `59.93% <52.98%> (-1.60%)` | :arrow_down: |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [.../apache/pulsar/client/api/MessageAcknowledger.java](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3B1bHNhci9jbGllbnQvYXBpL01lc3NhZ2VBY2tub3dsZWRnZXIuamF2YQ==) | `0.00% <ø> (ø)` | |
   | [...ent/impl/UnAckedTopicMessageRedeliveryTracker.java](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL1VuQWNrZWRUb3BpY01lc3NhZ2VSZWRlbGl2ZXJ5VHJhY2tlci5qYXZh) | `7.14% <0.00%> (ø)` | |
   | [...pulsar/client/impl/UnAckedTopicMessageTracker.java](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL1VuQWNrZWRUb3BpY01lc3NhZ2VUcmFja2VyLmphdmE=) | `43.75% <0.00%> (ø)` | |
   | [...ache/pulsar/client/impl/MultiTopicsReaderImpl.java](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL011bHRpVG9waWNzUmVhZGVySW1wbC5qYXZh) | `77.52% <40.00%> (+1.05%)` | :arrow_up: |
   | [...java/org/apache/pulsar/client/impl/ReaderImpl.java](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL1JlYWRlckltcGwuamF2YQ==) | `81.81% <40.00%> (+3.92%)` | :arrow_up: |
   | [...he/pulsar/client/impl/MultiTopicsConsumerImpl.java](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL011bHRpVG9waWNzQ29uc3VtZXJJbXBsLmphdmE=) | `71.44% <41.81%> (-3.90%)` | :arrow_down: |
   | [.../apache/pulsar/client/impl/BatchMessageIdImpl.java](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL0JhdGNoTWVzc2FnZUlkSW1wbC5qYXZh) | `95.00% <50.00%> (ø)` | |
   | [...rg/apache/pulsar/client/impl/TopicMessageImpl.java](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2NsaWVudC9pbXBsL1RvcGljTWVzc2FnZUltcGwuamF2YQ==) | `58.13% <50.00%> (ø)` | |
   | [...pulsar/broker/admin/impl/PersistentTopicsBase.java](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWJyb2tlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcHVsc2FyL2Jyb2tlci9hZG1pbi9pbXBsL1BlcnNpc3RlbnRUb3BpY3NCYXNlLmphdmE=) | `59.00% <51.37%> (-0.16%)` | :arrow_down: |
   | [...a/org/apache/pulsar/client/api/TopicMessageId.java](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHVsc2FyLWNsaWVudC1hcGkvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3B1bHNhci9jbGllbnQvYXBpL1RvcGljTWVzc2FnZUlkLmphdmE=) | `53.84% <53.84%> (ø)` | |
   | ... and [195 more](https://codecov.io/gh/apache/pulsar/pull/19158?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on code in PR #19158:
URL: https://github.com/apache/pulsar/pull/19158#discussion_r1091374965


##########
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/TopicMessageId.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.api;
+
+/**
+ * The MessageId used for a consumer that subscribes multiple topics or partitioned topics.
+ *
+ * <p>
+ * It's guaranteed that {@link Message#getMessageId()} must return a TopicMessageId instance if the Message is received
+ * from a consumer that subscribes multiple topics or partitioned topics.
+ * The topic name used in APIs related to this class like `getOwnerTopic` and `create` must be the full topic name. For
+ * example, "my-topic" is invalid while "persistent://public/default/my-topic" is valid.
+ * If the topic is a partitioned topic, the topic name should be the name of the specific partition, e.g.
+ * "persistent://public/default/my-topic-partition-0".
+ * </p>
+ */
+public interface TopicMessageId extends MessageId {
+
+    /**
+     * Return the owner topic name of a message.
+     *
+     * @return the owner topic
+     */
+    String getOwnerTopic();
+
+    static TopicMessageId create(String topic, MessageId messageId) {

Review Comment:
   Oh, sorry, I pushed it now.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] BewareMyPower commented on pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on PR #19158:
URL: https://github.com/apache/pulsar/pull/19158#issuecomment-1384038345

   @codelipenghui @congbobo184 @eolivelli @hangc0276 PTAL


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] codelipenghui commented on a diff in pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui commented on code in PR #19158:
URL: https://github.com/apache/pulsar/pull/19158#discussion_r1090351983


##########
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/MessageAcknowledger.java:
##########
@@ -49,6 +49,8 @@ public interface MessageAcknowledger {
      *
      * @throws PulsarClientException.AlreadyClosedException}
      *             if the consumer was already closed
+     * @throws PulsarClientException.NotAllowedException
+     *             if `messageId` is not a {@link TopicMessageId} when multiple topics are subscribed

Review Comment:
   And is it also for the partitioned topic? Users need to use 
   
   ```java
   MessageId.fromByteArrayWithTopic();
   ```
   
   or 
   
   ```java
   TopicMessageId.create(topic, MessageId.fromByteArray());
   ```
   
   Does the TopicMessageId interface is intentionally exposed to users? Which one should be suggested in the future?



##########
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/TopicMessageId.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.api;
+
+/**
+ * The MessageId used for a consumer that subscribes multiple topics or partitioned topics.
+ *
+ * <p>
+ * It's guaranteed that {@link Message#getMessageId()} must return a TopicMessageId instance if the Message is received
+ * from a consumer that subscribes multiple topics or partitioned topics.
+ * The topic name used in APIs related to this class like `getOwnerTopic` and `create` must be the full topic name. For
+ * example, "my-topic" is invalid while "persistent://public/default/my-topic" is valid.
+ * If the topic is a partitioned topic, the topic name should be the name of the specific partition, e.g.
+ * "persistent://public/default/my-topic-partition-0".
+ * </p>
+ */
+public interface TopicMessageId extends MessageId {
+
+    /**
+     * Return the owner topic name of a message.
+     *
+     * @return the owner topic
+     */
+    String getOwnerTopic();
+
+    static TopicMessageId create(String topic, MessageId messageId) {

Review Comment:
   We will create an anonymous implementation here. Is it better to have an internal static class? e.g., `TopicMessageIdBase` or `TopicMessageIdWrapper`, and then the `TopicMessageIdImpl` can extend the base class.
   
   We still need the `messageId` reference. Otherwise, it's not easy to get the actual message ID in the heap dump.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] BewareMyPower merged pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower merged PR #19158:
URL: https://github.com/apache/pulsar/pull/19158


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] Technoboy- closed pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- closed pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge
URL: https://github.com/apache/pulsar/pull/19158


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on code in PR #19158:
URL: https://github.com/apache/pulsar/pull/19158#discussion_r1090410931


##########
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/MessageAcknowledger.java:
##########
@@ -49,6 +49,8 @@ public interface MessageAcknowledger {
      *
      * @throws PulsarClientException.AlreadyClosedException}
      *             if the consumer was already closed
+     * @throws PulsarClientException.NotAllowedException
+     *             if `messageId` is not a {@link TopicMessageId} when multiple topics are subscribed

Review Comment:
   > Does the TopicMessageId interface is intentionally exposed to users? 
   
   Yes. The new `getLastTopicMessageId` APIs will return `TopicMessageId` instances, they will be introduced in another PR, see the [original PIP issue](https://github.com/apache/pulsar/issues/18616).. And users can avoid touching the `pulsar-client` module (internal implementations) to get the topic name of a message ID.
   
   ```java
   if (msgId instanceof TopicMessageId) {
       multiTopicsConsumer.seek(msgId);
   } else {
       multiTopicsConsumer.seek(TopicMessageId.create(topic, msgId));
   }
   ```
   
   > Which one should be suggested in the future?
   
   `fromByteArrayWithTopic` should be deprecated. The `MessageId` that is not a `TopicMessageId` could be retrieved from other ways, not only the deserialization. But `fromByteArrayWithTopic` assumes it (e.g. a `MessageIdImpl`) was retrieved from deserialization.
   



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] codelipenghui commented on a diff in pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

Posted by "codelipenghui (via GitHub)" <gi...@apache.org>.
codelipenghui commented on code in PR #19158:
URL: https://github.com/apache/pulsar/pull/19158#discussion_r1091356656


##########
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/TopicMessageId.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.api;
+
+/**
+ * The MessageId used for a consumer that subscribes multiple topics or partitioned topics.
+ *
+ * <p>
+ * It's guaranteed that {@link Message#getMessageId()} must return a TopicMessageId instance if the Message is received
+ * from a consumer that subscribes multiple topics or partitioned topics.
+ * The topic name used in APIs related to this class like `getOwnerTopic` and `create` must be the full topic name. For
+ * example, "my-topic" is invalid while "persistent://public/default/my-topic" is valid.
+ * If the topic is a partitioned topic, the topic name should be the name of the specific partition, e.g.
+ * "persistent://public/default/my-topic-partition-0".
+ * </p>
+ */
+public interface TopicMessageId extends MessageId {
+
+    /**
+     * Return the owner topic name of a message.
+     *
+     * @return the owner topic
+     */
+    String getOwnerTopic();
+
+    static TopicMessageId create(String topic, MessageId messageId) {

Review Comment:
   Looks like you haven't pushed the commit?



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [pulsar] BewareMyPower commented on a diff in pull request #19158: [improve][client] PIP-224 Part 1: Add TopicMessageId for seek and acknowledge

Posted by "BewareMyPower (via GitHub)" <gi...@apache.org>.
BewareMyPower commented on code in PR #19158:
URL: https://github.com/apache/pulsar/pull/19158#discussion_r1090428108


##########
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/TopicMessageId.java:
##########
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.client.api;
+
+/**
+ * The MessageId used for a consumer that subscribes multiple topics or partitioned topics.
+ *
+ * <p>
+ * It's guaranteed that {@link Message#getMessageId()} must return a TopicMessageId instance if the Message is received
+ * from a consumer that subscribes multiple topics or partitioned topics.
+ * The topic name used in APIs related to this class like `getOwnerTopic` and `create` must be the full topic name. For
+ * example, "my-topic" is invalid while "persistent://public/default/my-topic" is valid.
+ * If the topic is a partitioned topic, the topic name should be the name of the specific partition, e.g.
+ * "persistent://public/default/my-topic-partition-0".
+ * </p>
+ */
+public interface TopicMessageId extends MessageId {
+
+    /**
+     * Return the owner topic name of a message.
+     *
+     * @return the owner topic
+     */
+    String getOwnerTopic();
+
+    static TopicMessageId create(String topic, MessageId messageId) {

Review Comment:
   I changed it to an inner class.



-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org