Add Consumer.consumer_name() API (#206)
Catch up for https://github.com/apache/pulsar-client-cpp/pull/360
diff --git a/pulsar/__init__.py b/pulsar/__init__.py
index 9590fa3..fad33cd 100644
--- a/pulsar/__init__.py
+++ b/pulsar/__init__.py
@@ -1428,6 +1428,12 @@
"""
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.
diff --git a/src/consumer.cc b/src/consumer.cc
index 346673a..e32a865 100644
--- a/src/consumer.cc
+++ b/src/consumer.cc
@@ -112,6 +112,7 @@
.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)
diff --git a/tests/pulsar_test.py b/tests/pulsar_test.py
index a3b97b6..bb62d99 100755
--- a/tests/pulsar_test.py
+++ b/tests/pulsar_test.py
@@ -1886,5 +1886,13 @@
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()