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 2022/06/09 03:10:37 UTC

[GitHub] [pulsar] michaeljmarshall opened a new pull request, #15993: [client][python] Add support for consumer get_last_message_id

michaeljmarshall opened a new pull request, #15993:
URL: https://github.com/apache/pulsar/pull/15993

   Fixes #15985
   
   ### Motivation
   
   Add the `get_last_message_id` method to the python consumer. This method is already present in the C++ client.
   
   ### Modifications
   
   * Add method call to `consumer.cc`
   * Add test 
   
   ### Verifying this change
   
   There is a test to verify this change.
   
   ### Does this pull request potentially affect one of the following parts:
   
   It expands the python client library.
   
   ### Documentation
   Docs will be auto-generated for this addition.


-- 
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] michaeljmarshall commented on a diff in pull request #15993: [client][python] Add support for consumer get_last_message_id

Posted by GitBox <gi...@apache.org>.
michaeljmarshall commented on code in PR #15993:
URL: https://github.com/apache/pulsar/pull/15993#discussion_r893886448


##########
pulsar-client-cpp/python/pulsar_test.py:
##########
@@ -486,6 +486,23 @@ def test_consumer_is_connected(self):
         self.assertFalse(consumer.is_connected())
         client.close()
 
+    def test_consumer_get_last_message_id(self):
+        client = Client(self.serviceUrl)
+        topic = "test_consumer_get_last_message_id"
+        sub = "sub"
+        consumer = client.subscribe(topic, sub)
+
+        producer = client.create_producer(topic)
+
+        for i in range(10):
+            producer.send(b"hello-%d" % i)
+            message_id = consumer.get_last_message_id()

Review Comment:
   Sure, I can cover that test too. I need to address the underlying C++ first, though.



-- 
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] github-actions[bot] commented on pull request #15993: [client][python] Add support for consumer get_last_message_id

Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on PR #15993:
URL: https://github.com/apache/pulsar/pull/15993#issuecomment-1150620596

   @michaeljmarshall:Thanks for your contribution. For this PR, do we need to update docs?
   (The [PR template contains info about doc](https://github.com/apache/pulsar/blob/master/.github/PULL_REQUEST_TEMPLATE.md#documentation), which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)


-- 
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] michaeljmarshall closed pull request #15993: [client][python] Add support for consumer get_last_message_id

Posted by GitBox <gi...@apache.org>.
michaeljmarshall closed pull request #15993: [client][python] Add support for consumer get_last_message_id
URL: https://github.com/apache/pulsar/pull/15993


-- 
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] michaeljmarshall commented on pull request #15993: [client][python] Add support for consumer get_last_message_id

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

   Looks like this is superseded by one or more PRs. I'll close this for 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 a diff in pull request #15993: [client][python] Add support for consumer get_last_message_id

Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on code in PR #15993:
URL: https://github.com/apache/pulsar/pull/15993#discussion_r893050813


##########
pulsar-client-cpp/include/pulsar/Consumer.h:
##########
@@ -390,6 +390,11 @@ class PULSAR_PUBLIC Consumer {
      */
     bool isConnected() const;
 
+    /**
+     * Get the latest message id for the consumer's topic.
+     */
+    virtual void getLastMessageIdAsync(BrokerGetLastMessageIdCallback callback);

Review Comment:
   `BrokerGetLastMessageIdCallback` is an internal callback definition defined in `ConsumerImpl.h`, you should define your own callback. See `include/pulsar/Reader.h` for how it defines the `getLastMessageIdAsync`. And there is no need to make it `virtual`.



-- 
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] michaeljmarshall commented on a diff in pull request #15993: [client][python] Add support for consumer get_last_message_id

Posted by GitBox <gi...@apache.org>.
michaeljmarshall commented on code in PR #15993:
URL: https://github.com/apache/pulsar/pull/15993#discussion_r893052699


##########
pulsar-client-cpp/include/pulsar/Consumer.h:
##########
@@ -390,6 +390,11 @@ class PULSAR_PUBLIC Consumer {
      */
     bool isConnected() const;
 
+    /**
+     * Get the latest message id for the consumer's topic.
+     */
+    virtual void getLastMessageIdAsync(BrokerGetLastMessageIdCallback callback);

Review Comment:
   Thank you for your guidance! I'll take a look at that.



-- 
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] eolivelli commented on a diff in pull request #15993: [client][python] Add support for consumer get_last_message_id

Posted by GitBox <gi...@apache.org>.
eolivelli commented on code in PR #15993:
URL: https://github.com/apache/pulsar/pull/15993#discussion_r893101568


##########
pulsar-client-cpp/python/pulsar_test.py:
##########
@@ -486,6 +486,23 @@ def test_consumer_is_connected(self):
         self.assertFalse(consumer.is_connected())
         client.close()
 
+    def test_consumer_get_last_message_id(self):
+        client = Client(self.serviceUrl)
+        topic = "test_consumer_get_last_message_id"
+        sub = "sub"
+        consumer = client.subscribe(topic, sub)
+
+        producer = client.create_producer(topic)
+
+        for i in range(10):
+            producer.send(b"hello-%d" % i)
+            message_id = consumer.get_last_message_id()

Review Comment:
   we should add a test with a empty topic
   
   possibly we should cover the case of a truncated topic, but I am not sure we have a API to truncate a topic in python. not a blocker



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