Skip to content

Commit df5186c

Browse files
unbearablesartembilan
authored andcommitted
Add convenient StreamListenerContainer.getStreamName()
It would be nice to have `StreamListenerContainer.getStreamName()` method to fulfill need to dynamically stop/start listeners in reaction of broker events. Let's say I need to react to RabbitMQ broker events of queue.created / queue.deleted and I need to start and stop listeners, which are assigned to these streams. Currently I need to create an extra map of `listenerId` to `streamName` OR include `streamName` in `listenerId` (e.g. `listener:{streamName}`) to be able to carry our operations on listener. A simple getter for `streamName` on the `StreamListenerContainer` would allow me to react to these changes dynamically without extra code effort. Signed-off-by: David Horak <[email protected]> [[email protected]: Fix JavaDoc for a new method. Fix Commit message] Fixes: #2961 Signed-off-by: Artem Bilan <[email protected]> # Conflicts: # spring-rabbit-stream/src/main/java/org/springframework/rabbit/stream/listener/StreamListenerContainer.java
1 parent bbc23c3 commit df5186c

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

spring-rabbit-stream/src/main/java/org/springframework/rabbit/stream/listener/StreamListenerContainer.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@
5656
* @author Gary Russell
5757
* @author Christian Tzolov
5858
* @author Ngoc Nhan
59+
* @author Artem Bilan
60+
* @author David Horak
61+
*
5962
* @since 2.4
6063
*
6164
*/
@@ -111,6 +114,15 @@ public StreamListenerContainer(Environment environment, @Nullable Codec codec) {
111114
this.streamConverter = new DefaultStreamMessageConverter(codec);
112115
}
113116

117+
/**
118+
* Get a stream name this listener is subscribed to.
119+
* @return the stream name this listener is subscribed to.
120+
* @since 3.2.3
121+
*/
122+
public String getStreamName() {
123+
return this.streamName;
124+
}
125+
114126
/**
115127
* {@inheritDoc}
116128
* Mutually exclusive with {@link #superStream(String, String)}.

0 commit comments

Comments
 (0)