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 <horak.david@protonmail.com>

[artem.bilan@broadcom.com: Fix JavaDoc for a new method. Fix Commit message]

**Auto-cherry-pick to `3.2.x`**

Signed-off-by: Artem Bilan <artem.bilan@broadcom.com>
This commit is contained in:
David Horak
2025-02-10 21:46:00 +01:00
committed by GitHub
parent ea16a02cee
commit 0729a57fc6

View File

@@ -57,6 +57,7 @@ import org.springframework.util.Assert;
* @author Christian Tzolov
* @author Ngoc Nhan
* @author Artem Bilan
* @author David Horak
*
* @since 2.4
*
@@ -117,6 +118,15 @@ public class StreamListenerContainer extends ObservableListenerContainer {
: new DefaultStreamMessageConverter();
}
/**
* Get a stream name this listener is subscribed to.
* @return the stream name this listener is subscribed to.
* @since 3.2.3
*/
public String getStreamName() {
return this.streamName;
}
/**
* {@inheritDoc}
* Mutually exclusive with {@link #superStream(String, String)}.