Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions pulsar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1428,6 +1428,12 @@ def subscription_name(self):
"""
return self._consumer.subscription_name()

def consumer_name(self):
"""
Return the consumer name.
"""
return self._consumer.consumer_name()

def unsubscribe(self):
"""
Unsubscribe the current consumer from the topic.
Expand Down
1 change: 1 addition & 0 deletions src/consumer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ void export_consumer(py::module_& m) {
.def("topic", &Consumer::getTopic, "return the topic this consumer is subscribed to",
py::return_value_policy::copy)
.def("subscription_name", &Consumer::getSubscriptionName, py::return_value_policy::copy)
.def("consumer_name", &Consumer::getConsumerName, py::return_value_policy::copy)
.def("unsubscribe", &Consumer_unsubscribe)
.def("receive", &Consumer_receive)
.def("receive", &Consumer_receive_timeout)
Expand Down
8 changes: 8 additions & 0 deletions tests/pulsar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1886,5 +1886,13 @@ def test_regex_subscription(self):

client.close()

def test_consumer_name(self):
client = Client(self.serviceUrl)
name = 'my-consumer-name'
consumer = client.subscribe('test_consumer_name', 'sub', consumer_name=name)
self.assertEqual(consumer.consumer_name(), name)
client.close()


if __name__ == "__main__":
main()