Skip to content

Commit 0729a57

Browse files
authored
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] **Auto-cherry-pick to `3.2.x`** Signed-off-by: Artem Bilan <[email protected]>
1 parent ea16a02 commit 0729a57

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

+10
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
* @author Christian Tzolov
5858
* @author Ngoc Nhan
5959
* @author Artem Bilan
60+
* @author David Horak
6061
*
6162
* @since 2.4
6263
*
@@ -117,6 +118,15 @@ public StreamListenerContainer(Environment environment, @Nullable Codec codec) {
117118
: new DefaultStreamMessageConverter();
118119
}
119120

121+
/**
122+
* Get a stream name this listener is subscribed to.
123+
* @return the stream name this listener is subscribed to.
124+
* @since 3.2.3
125+
*/
126+
public String getStreamName() {
127+
return this.streamName;
128+
}
129+
120130
/**
121131
* {@inheritDoc}
122132
* Mutually exclusive with {@link #superStream(String, String)}.

0 commit comments

Comments
 (0)