forked from apache/pulsar
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[pulsar-client] Avoid subscribing the same topic again (apache#7823)
### Motivation The current key of `MultiTopicsConsumerImpl.topics` is the topic name passed by user. The `topicNameValid` method checks if the name is valid and `topics` doesn't contain the key. However, if a multi topics consumer subscribed a partition of a subscribed partitioned topic, `subscribeAsync` succeed and a new `ConsumerImpl` of the same partition was created, which is redundant. Also, if a multi topics consumer subscribed `public/default/topic` or `persistent://public/default/topic`, while the initial subscribed topic is `topic`, the redundant consumers would be created. ### Modifications - Use full topic name as key of `MultiTopicsConsumerImpl.topics` - Check both full topic name and full partitioned topic name not exist in `MultiTopicsConsumerImpl.topics` when `subscribeAsync` is called - Throw a different exception to differ topic is invalid and topic is already subscribed - Add a unit test for subscribing a partition of a subscribed partitioned topic or the same topic with prefix
- Loading branch information
1 parent
bc5be21
commit e1b76a3
Showing
3 changed files
with
80 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters