nodece commented on code in PR #21873:
URL: https://github.com/apache/pulsar/pull/21873#discussion_r1448935171


##########
pip/pip-330.md:
##########
@@ -0,0 +1,43 @@
+# PIP-330: getMessageById gets all messages
+
+# Motivation
+
+The `org.apache.pulsar.client.admin.Topics` provides 
`getMessageById(java.lang.String, long, long)` method to get the
+message, which returns one message. If the message id refers to a batch 
message, we only can get the first message, not
+all messages.
+
+This behavior affects our analysis of messages by the message id.
+
+# Goals
+
+## In Scope
+
+Add a method that returns all messages by message id to the 
`org.apache.pulsar.client.admin.Topics` interface.
+
+# Detailed Design
+
+## Design & Implementation Details
+
+Add `getMessageById(java.lang.String, java.lang.String)` to 
`org.apache.pulsar.client.admin.Topics` interface:
+
+```java
+public interface Topics {
+    List<Message<byte[]>> getMessageById(String topic, String messageId) 
throws PulsarAdminException;

Review Comment:
   > It seems like you can retain the exact signature we have today:
   > 
   > ```
   >   public Message<byte[]> getMessageById(String topic, long ledgerId, long 
entryId)
   > ```
   
   I should add `@Deprecate` for `public Message<byte[]> getMessageById(String 
topic, long ledgerId, long entryId)`.
   
   We need to consider the batch message(msg1, msg2, msg3), when you use the 
method, you can only get the `msg1`, not all. This will create a false 
impression that the user thinks there is only one message.
   
   
   
   > and perhaps change the name to signify you will get _all_ messages:
   > 
   > ```
   >   public Message<byte[]> getAllMessagesById(String topic, long ledgerId, 
long entryId)
   > ```
   > 
   > and you can add to get a specific one, by the batch index:
   > 
   > ```
   >   public Message<byte[]> getMessageById(String topic, long ledgerId, long 
entryId, long batchIndex)
   > ```
   
   I prefer to `public Message<byte[]> getMessageById(String topic, long 
ledgerId, long entryId, long batchIndex)`, when batchIndex is greater than -1, 
we can extract the specific one from the batch message by batchIndex.
   
   The current discussion point is whether we should use a `String` parameter 
or multiple parameters(`long ledgerId, long entryId, long batchIndex`). IMO, 
everything is fine.
   
   
   
   
   
   



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