Multi-Topic subscription across tenant and namespace using regex in Java client throws IllegalArgumentException #18862
Replies: 3 comments
-
@rnowacoski currently regex subscription supports the topics in the same namespace. change this issue into a feature request. from my view, it is not hard to do, maybe we should pay more attention to the authorization. |
Beta Was this translation helpful? Give feedback.
-
Closed as stale. Please create a new issue if it's still relevant to the maintained versions. |
Beta Was this translation helpful? Give feedback.
-
Moved to discussion forum. This seems an interesting feature request, but it requires volunteers work on it and more design details. Whether or not support regexp in looking up tenant/ns/topic has no consensus yet. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Describe the bug
When using a regex to create a consumer and a regex pattern is present in the tenant or namespace section of the pattern this error is thrown.
Example pattern:
persistent://\w+/Test/Test1
orpersistent://Test/\w+/Test1
This is because
PulsarClientImpl.patternTopicSubscribeAsync
is called when creating a consumer using a Pattern. This callstopicName.get(regex);
where regex is the Pattern passed in. This method attempts to validate the tenant and namespace names against this regex^[-=:.\\w]*$
in org.apache.pulsar.common.naming.NamedEntity. This fails for any regex pattern. The namespace name is needed in the current code because it is used byLookupService.getTopicsUnderNamespace
to find the topics to subscribe to.To Reproduce
Steps to reproduce the behavior:
java.lang.IllegalArgumentException: Invalid named entity: \w+
is thrownExpected behavior
Given a wildcard in a tenant or namespace I would expect the code to look up all tenants/namespaces that match and then lookup all topics to subscribe to.
Proposed Solution
getNamespaces()
that will return all tenant/namespaces.PulsarClientImpl.patternTopicSubscribeAsync
should filter these namespaces based on the regex givenPulsarClientImpl.patternTopicSubscribeAsync
should callLookupService.getTopicsUnderNamespace
Beta Was this translation helpful? Give feedback.
All reactions