BewareMyPower commented on code in PR #134:
URL:
https://github.com/apache/pulsar-client-python/pull/134#discussion_r1288759613
##########
tests/pulsar_test.py:
##########
@@ -1718,6 +1718,39 @@ def test_batch_index_ack(self):
client.close()
+ def test_regex_subscription(self):
+ import re
Review Comment:
You move this line at the topic of this test file and then remove
`test_topics_pattern_consumer`.
##########
tests/pulsar_test.py:
##########
@@ -1718,6 +1718,39 @@ def test_batch_index_ack(self):
client.close()
+ def test_regex_subscription(self):
+ import re
+
+ client = Client(self.serviceUrl)
+ topic1 = "persistent://public/default/test-regex-sub-1"
+ topic2 = "persistent://public/default/test-regex-sub-2"
+ topic3 = "non-persistent://public/default/test-regex-sub-3"
+ topic4 = "persistent://public/default/no-match-test-regex-sub-3" # no
match pattern rule topic.
+
+ producer1 = client.create_producer(topic1)
+ producer2 = client.create_producer(topic2)
+ producer3 = client.create_producer(topic3)
+ producer4 = client.create_producer(topic4)
+
+ consumer = client.subscribe(
+ re.compile('public/default/test-regex-sub-.*'), "regex-sub",
consumer_type=ConsumerType.Shared,
+ regex_subscription_mode=RegexSubscriptionMode.AllTopics
+ )
+
+ num = 10
+ for i in range(num):
+ producer1.send(b"hello-1-%d" % i)
+ producer2.send(b"hello-2-%d" % i)
+ producer3.send(b"hello-3-%d" % i)
+ producer4.send(b"hello-4-%d" % i)
+
+ for i in range(3 * num):
Review Comment:
Could you add more strict checks? You can get the topic from `msg` and check
all messages come from `topic1`, `topic2` and `topic3`?
##########
tests/pulsar_test.py:
##########
@@ -1718,6 +1718,39 @@ def test_batch_index_ack(self):
client.close()
+ def test_regex_subscription(self):
+ import re
+
+ client = Client(self.serviceUrl)
+ topic1 = "persistent://public/default/test-regex-sub-1"
+ topic2 = "persistent://public/default/test-regex-sub-2"
+ topic3 = "non-persistent://public/default/test-regex-sub-3"
+ topic4 = "persistent://public/default/no-match-test-regex-sub-3" # no
match pattern rule topic.
+
+ producer1 = client.create_producer(topic1)
+ producer2 = client.create_producer(topic2)
+ producer3 = client.create_producer(topic3)
+ producer4 = client.create_producer(topic4)
+
+ consumer = client.subscribe(
+ re.compile('public/default/test-regex-sub-.*'), "regex-sub",
consumer_type=ConsumerType.Shared,
+ regex_subscription_mode=RegexSubscriptionMode.AllTopics
Review Comment:
Could you create multiple consumers with different regex subscription mode?
--
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]