Skip to content
Open
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
1 change: 1 addition & 0 deletions pulsar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1398,6 +1398,7 @@ def my_listener(consumer, message):
conf = _pulsar.ConsumerConfiguration()
conf.consumer_type(consumer_type)
conf.regex_subscription_mode(regex_subscription_mode)
conf.pattern_auto_discovery_period(pattern_auto_discovery_period)
conf.read_compacted(is_read_compacted)
if message_listener:
conf.message_listener(_listener_wrapper(message_listener, schema))
Expand Down
12 changes: 8 additions & 4 deletions tests/pulsar_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1366,22 +1366,26 @@ def test_topics_pattern_consumer(self):

doHttpPut(url1, "2")
doHttpPut(url2, "3")
doHttpPut(url3, "4")

producer1 = client.create_producer(topic1)
producer2 = client.create_producer(topic2)
producer3 = client.create_producer(topic3)

consumer = client.subscribe(
re.compile(topics_pattern),
"my-pattern-consumer-sub",
consumer_type=ConsumerType.Shared,
receiver_queue_size=10,
pattern_auto_discovery_period=1,
initial_position=InitialPosition.Earliest,
)

# wait enough time to trigger auto discovery
time.sleep(2)
# topic3 is created after the subscription, so the consumer can only get it through auto discovery.
# Expected: found about 1 second after the subscription since pattern_auto_discovery_period=1. Before
# the fix the period was never applied, so the C++ default of 60 seconds was used (issue 171).
# There is no fixed sleep: the receive() calls below wait up to TM (10 seconds) for each message,
# which is far below 60 seconds, so the test still times out without the fix.
doHttpPut(url3, "4")
producer3 = client.create_producer(topic3)

for i in range(100):
producer1.send(b"hello-1-%d" % i)
Expand Down