-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Description
Describe the bug
I am trying to use non persistent topic on pulsar 2.7.2 non persistent topic. Pulsar cluster disallow auto subscription creation, allowAutoSubscriptionCreation=false.
I tried to create subscription using pulsar admin api but receiving error Create subscription on non-persistent topic can only be done through client
To Reproduce
Steps to reproduce the behavior:
- Delopy a Pulsar cluster with
allowAutoSubscriptionCreation=false - Create a non persistent topic
non-persistent://test/test/topic1 - Create a consumer to subscribe the topic
- See error
Expected behavior
The consumer can subscribe the non persistent topic correctly.
Additional context
The pulsar admin disallow creating subscription on non persistent topic:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/v2/PersistentTopics.java
Lines 1347 to 1350 in 016fb87
| if (!topicName.isPersistent()) { | |
| throw new RestException(Response.Status.BAD_REQUEST, "Create subscription on non-persistent topic" | |
| + "can only be done through client"); | |
| } |
The broker reject the subscription:
pulsar/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
Lines 1013 to 1022 in 016fb87
| boolean rejectSubscriptionIfDoesNotExist = isDurable | |
| && !service.isAllowAutoSubscriptionCreation(topicName.toString()) | |
| && !topic.getSubscriptions().containsKey(subscriptionName); | |
| if (rejectSubscriptionIfDoesNotExist) { | |
| return FutureUtil | |
| .failedFuture( | |
| new SubscriptionNotFoundException( | |
| "Subscription does not exist")); | |
| } |