Skip to content

Conversation

@michaeljmarshall
Copy link
Member

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.

@github-actions
Copy link

github-actions bot commented Jun 9, 2022

@michaeljmarshall:Thanks for your contribution. For this PR, do we need to update docs?
(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@michaeljmarshall michaeljmarshall added type/feature The PR added a new feature or issue requested a new feature doc-complete Your PR changes impact docs and the related docs have been already added. and removed doc-not-needed Your PR changes do not impact docs labels Jun 9, 2022
/**
* Get the latest message id for the consumer's topic.
*/
virtual void getLastMessageIdAsync(BrokerGetLastMessageIdCallback callback);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


for i in range(10):
producer.send(b"hello-%d" % i)
message_id = consumer.get_last_message_id()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

BewareMyPower pushed a commit that referenced this pull request Jun 23, 2022
### Motivation

Add getLastMessageId method to C++ Consumer.cc to address the missing part in this PR #15993

### Modifications

Expose methods to get last message Id in consumer, the C++ client's Consumer class
@michaeljmarshall
Copy link
Member Author

Looks like this is superseded by one or more PRs. I'll close this for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc-complete Your PR changes impact docs and the related docs have been already added. type/feature The PR added a new feature or issue requested a new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add getLastMessageId feature to Python Client

3 participants