Add unregisterListenerContainer to PulsarListenerEndpointRegistry - #1553
Open
dlwhdgus0810 wants to merge 1 commit into
Open
dlwhdgus0810 wants to merge 1 commit into
dlwhdgus0810 wants to merge 1 commit into
Conversation
PulsarListenerEndpointRegistry supports registering listener containers at runtime via registerListenerContainer, but offers no way to remove them. Applications that recreate listeners dynamically therefore cannot reuse endpoint ids, and the registry keeps growing with stale containers. Add GenericListenerEndpointRegistry#unregisterListenerContainer(String), mirroring KafkaListenerEndpointRegistry in Spring for Apache Kafka. The method only removes the container from the registry and returns it; it does not stop or destroy the container, which remains the caller's responsibility. Resolves spring-projects#1552 Signed-off-by: Hyun Lee <dlwhdugs4147@gmail.com>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PulsarListenerEndpointRegistrylets you register listener containers at runtime withregisterListenerContainer(...), but there is no way to remove one again. When listeners are recreated dynamically (for example per tenant/namespace, as described in #1552), the old container stays in the registry even after it has been stopped and destroyed. Endpoint ids can't be reused, and the registry keeps growing.This adds
unregisterListenerContainer(String id)toGenericListenerEndpointRegistry, soPulsarListenerEndpointRegistryinherits it. It works likeKafkaListenerEndpointRegistry#unregisterListenerContainer(String)in Spring for Apache Kafka:nullif nothing was registered under that id.getListenerContainer(String)does.Example:
I used
@since 2.0.8becausemainis on 2.0.8-SNAPSHOT (Spring Kafka also added this method in a patch release, 2.8.9). I can change it if this should go into a later version. I didn't add a What's New entry because that page is organized by minor release, but I can add one if you want.Testing
New
PulsarListenerEndpointRegistryTestschecks that:nullCommands:
./gradlew :spring-pulsar:test --tests 'org.springframework.pulsar.config.*'passes, including the 3 new tests../gradlew :spring-pulsar:checkstyleMain :spring-pulsar:checkstyleTest :spring-pulsar:javadocpasses.Resolves #1552