Skip to content

Commit bef33a8

Browse files
garyrussellartembilan
authored andcommitted
GH-796: RLEndpointRegistry - unregister
Resolves #796 Support removal of containers from the registry. **cherry-pick to 2.0.x** (cherry picked from commit 1ed2b12)
1 parent 70bc3d2 commit bef33a8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

spring-rabbit/src/main/java/org/springframework/amqp/rabbit/listener/RabbitListenerEndpointRegistry.java

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2014-2017 the original author or authors.
2+
* Copyright 2014-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@
3838
import org.springframework.context.ConfigurableApplicationContext;
3939
import org.springframework.context.SmartLifecycle;
4040
import org.springframework.context.event.ContextRefreshedEvent;
41+
import org.springframework.lang.Nullable;
4142
import org.springframework.util.Assert;
4243
import org.springframework.util.StringUtils;
4344

@@ -141,7 +142,7 @@ public void registerListenerContainer(RabbitListenerEndpoint endpoint, RabbitLis
141142
*/
142143
@SuppressWarnings("unchecked")
143144
public void registerListenerContainer(RabbitListenerEndpoint endpoint, RabbitListenerContainerFactory<?> factory,
144-
boolean startImmediately) {
145+
boolean startImmediately) {
145146
Assert.notNull(endpoint, "Endpoint must not be null");
146147
Assert.notNull(factory, "Factory must not be null");
147148

@@ -201,6 +202,16 @@ protected MessageListenerContainer createListenerContainer(RabbitListenerEndpoin
201202
return listenerContainer;
202203
}
203204

205+
/**
206+
* Remove a listener container from the registry.
207+
* @param id the container id.
208+
* @return the container, or null if there is no registration matching the id.
209+
* @since 2.0.6
210+
*/
211+
@Nullable
212+
public MessageListenerContainer unregisterListenerContainer(String id) {
213+
return this.listenerContainers.remove(id);
214+
}
204215

205216
@Override
206217
public void destroy() {

0 commit comments

Comments
 (0)