BewareMyPower commented on code in PR #22698:
URL: https://github.com/apache/pulsar/pull/22698#discussion_r1597445741


##########
pulsar-client/src/main/java/org/apache/pulsar/client/util/MessageIdUtils.java:
##########
@@ -19,11 +19,12 @@
 package org.apache.pulsar.client.util;
 
 import org.apache.pulsar.client.api.MessageId;
+import org.apache.pulsar.client.api.MessageIdAdv;
 import org.apache.pulsar.client.impl.MessageIdImpl;
 
 public class MessageIdUtils {

Review Comment:
   This util class was introduced at very early era. It's better to add the 
util function to `MessageIdAdvUtils` for `MessageIdAdv`.
   
   And I don't think it's worth providing a util function for `MessageIdAdv` in 
the Pulsar core repo. `MessageIdAdv` is introduced mainly for this reason. The 
downstream application should cast `MessageId` to `MessageIdAdv` to access the 
internal fields.  It should not depend on the wrapped APIs from the upstream.
   
   Pulsar does not have the "offset" concept, the same logic is only used in 
the Kafka sink connector, but it does not call this util method directly. See 
https://github.com/apache/pulsar/blob/e558cfe9836256065befb3ff6d6043eca10aa5ef/pulsar-io/kafka-connect-adaptor/src/main/java/org/apache/pulsar/io/kafka/connect/KafkaConnectSink.java#L376
   
   To get the offset, it's better to leverage the 
`AppendIndexMetadataInterceptor` like KoP. See the discussion here: 
https://github.com/streamnative/kop/issues/290



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