Anonymitaet commented on a change in pull request #7240:
URL: https://github.com/apache/pulsar/pull/7240#discussion_r438696458
##########
File path: site2/docs/client-libraries-java.md
##########
@@ -379,18 +379,35 @@ ConsumerBuilder consumerBuilder =
pulsarClient.newConsumer()
.subscriptionName(subscription);
// Subscribe to all topics in a namespace
-Pattern allTopicsInNamespace =
Pattern.compile("persistent://public/default/.*");
+Pattern allTopicsInNamespace = Pattern.compile("public/default/.*");
Consumer allTopicsConsumer = consumerBuilder
.topicsPattern(allTopicsInNamespace)
.subscribe();
// Subscribe to a subsets of topics in a namespace, based on regex
-Pattern someTopicsInNamespace =
Pattern.compile("persistent://public/default/foo.*");
+Pattern someTopicsInNamespace = Pattern.compile("public/default/foo.*");
Consumer allTopicsConsumer = consumerBuilder
.topicsPattern(someTopicsInNamespace)
.subscribe();
```
+In the above example, the consumer subscribes to the `persistent` topics that
can match the topic name pattern,
+If you want the consumer subscribes to all `persistent` and `non-persistent`
topics that can match the topic pattern,
+You need to set `subscriptionTopicsMode` to `RegexSubscriptionMode.AllTopics`.
+
+```java
+Pattern pattern = Pattern.compile("public/default/.*");
+pulsarClient.newConsumer()
+ .subscriptionName("my-sub")
+ .topicsPattern(pattern)
+ .subscriptionTopicsMode(RegexSubscriptionMode.AllTopics)
+ .subscribe();
+```
+
+> Note:
+>
+> By default, the `subscriptionTopicsMode` of the consumer is
`PersistentOnly`. Available options are `PersistentOnly`, `NonPersistentOnly`
and `AllTopics`
Review comment:
```suggestion
> #### Note
>
> By default, the `subscriptionTopicsMode` of the consumer is
`PersistentOnly`. Available options of `subscriptionTopicsMode` are
`PersistentOnly`, `NonPersistentOnly`, and `AllTopics`.
```
##########
File path: site2/docs/client-libraries-java.md
##########
@@ -379,18 +379,35 @@ ConsumerBuilder consumerBuilder =
pulsarClient.newConsumer()
.subscriptionName(subscription);
// Subscribe to all topics in a namespace
-Pattern allTopicsInNamespace =
Pattern.compile("persistent://public/default/.*");
+Pattern allTopicsInNamespace = Pattern.compile("public/default/.*");
Consumer allTopicsConsumer = consumerBuilder
.topicsPattern(allTopicsInNamespace)
.subscribe();
// Subscribe to a subsets of topics in a namespace, based on regex
-Pattern someTopicsInNamespace =
Pattern.compile("persistent://public/default/foo.*");
+Pattern someTopicsInNamespace = Pattern.compile("public/default/foo.*");
Consumer allTopicsConsumer = consumerBuilder
.topicsPattern(someTopicsInNamespace)
.subscribe();
```
+In the above example, the consumer subscribes to the `persistent` topics that
can match the topic name pattern,
+If you want the consumer subscribes to all `persistent` and `non-persistent`
topics that can match the topic pattern,
+You need to set `subscriptionTopicsMode` to `RegexSubscriptionMode.AllTopics`.
Review comment:
```suggestion
In the above example, the consumer subscribes to the `persistent` topics
that can match the topic name pattern. If you want the consumer subscribes to
all `persistent` and `non-persistent` topics that can match the topic name
pattern, set `subscriptionTopicsMode` to `RegexSubscriptionMode.AllTopics`.
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]