eolivelli commented on a change in pull request #11553:
URL: https://github.com/apache/pulsar/pull/11553#discussion_r683800227
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerEntryMetadataE2ETest.java
##########
@@ -273,6 +274,32 @@ public void testGetLastMessageId() throws Exception {
.subscriptionType(SubscriptionType.Exclusive)
.subscriptionName(subscription)
.subscribe();
- consumer.getLastMessageId();
+ }
+
+ @Test(timeOut = 20000)
+ public void testConsumerGetBrokerEntryMetadata() throws Exception {
+ final String topic = newTopicName();
+ final String subscription = "my-sub";
+
+ @Cleanup
+ Producer<byte[]> producer = pulsarClient.newProducer()
+ .topic(topic)
+ .create();
+
+ @Cleanup
+ Consumer<byte[]> consumer = pulsarClient.newConsumer()
+ .topic(topic)
+ .subscriptionType(SubscriptionType.Exclusive)
+ .subscriptionName(subscription)
+ .subscribe();
+
+ long sendTime = System.currentTimeMillis();
+ producer.send("hello".getBytes());
+
+ Message<byte[]> received = consumer.receive();
+ Assert.assertEquals("hello", new String(received.getData()));
+
+ Assert.assertTrue(received.getBrokerPublishTime() >= sendTime);
+ Assert.assertEquals(received.getIndex(), 0);
Review comment:
Zero is an unfortunate value, can we test some value that we are sure it
is not a typical default value?
##########
File path:
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Message.java
##########
@@ -245,4 +245,20 @@
* @since 2.8.0
*/
void release();
+
+ /**
+ * Get broker publish time from broker entry metadata.
Review comment:
Please explain that this value is not available if the broker is older
or it does not enable this feature.
What about Optional<Long> ?
##########
File path:
pulsar-client-api/src/main/java/org/apache/pulsar/client/api/Message.java
##########
@@ -245,4 +245,20 @@
* @since 2.8.0
*/
void release();
+
+ /**
+ * Get broker publish time from broker entry metadata.
+ *
+ * @since 2.9.0
+ * @return broker publish time from broker entry metadata
+ */
+ long getBrokerPublishTime();
+
+ /**
+ * Get index from broker entry metadata.
+ *
+ * @Since 2.9.0
+ * @return index from broker entry metadata
+ */
+ long getIndex();
Review comment:
The same here.
Also, can you briefly explain what is the meaning of this index?
--
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]