BewareMyPower commented on code in PR #21873:
URL: https://github.com/apache/pulsar/pull/21873#discussion_r1450156239
##########
pip/pip-330.md:
##########
@@ -0,0 +1,55 @@
+# 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 can only 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 or specified message by message id to
the `org.apache.pulsar.client.admin.Topics` interface.
+
+# Detailed Design
+
+## Design & Implementation Details
+
+1. Add a set of methods to the `org.apache.pulsar.client.admin.Topics`
interface:
+
+```java
+public interface Topics {
+ // When batchIndex is greater than or equal to 0, return the specified
message.
+ List<Message<byte[]>> getMessageById(String topic, long ledgerId, long
entryId, Long batchIndex) throws PulsarAdminException;
+ CompletableFuture<List<Message<byte[]>>> getMessageByIdAsync(String topic,
long ledgerId, long entryId, Long batchIndex);
Review Comment:
A null integer is anti-intuitive.
From my perspective, removing the `batchIndex` field would be better.
```java
// Get all messages in the entry, if the entry is not batched, return a
singleton list
CompletableFuture<List<Message<byte[]>>> getAllMessagesByIdAsync(String
topic, long ledgerId, long entryId);
```
Otherwise, if users specified a batch index that is not valid, there is no
good way to handle it. What's important is, users cannot know how many messages
are stored in an entry in advance.
--
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]