How to subscribe to a list of multiple kafka wildcard patterns using kafka-python?
In the KafkaConsumer code, it supports list of topics, or a pattern,
https://github.com/dpkp/kafka-python/blob/68c8fa4ad01f8fef38708f257cb1c261cfac01ab/kafka/consumer/group.py#L717
def subscribe(self, topics=(), pattern=None, listener=None):
"""Subscribe to a list of topics, or a topic regex pattern
Partitions will be dynamically assigned via a group coordinator.
Topic subscriptions are not incremental: this list will replace the
current assignment (if there is one).
So you can create a regex, with OR condition using |
, that should work as subscribe to multiple dynamic topics regex, as it internally uses re
module for matching.
(customer.*.validations)|(customer.*.additional-validations)