Skip to content

Add support for SubscriptionListener to listen to [P][UN]SUBSCRIBE notifications #2054

@mp911de

Description

@mp911de

Registering a MessageListener with RedisMessageListenerContainer or starting to receive messages from RedisMessageListenerContainer requires awaiting until the actual subscription has been registered with Redis. Since subscribing triggers asynchronous activity, the only means to synchronize are sleep timers.

It would be good to actually consume Redis subscription confirmations to [P][UN]SUBSCRIBE commands through an interface along the lines of:

public interface SubscriptionListener {

	SubscriptionListener EMPTY = new SubscriptionListener() {};

	default void onChannelSubscribed(byte[] channel, long count) {}

	default void onChannelUnsubscribed(byte[] channel, long count) {}

	default void onPatternSubscribed(byte[] pattern, long count) {}

	default void onPatternUnsubscribed(byte[] pattern, long count) {}

}

It should be possible to let a MessageListener class implement SubscriptionListener to bind the actual notifications to the message listener.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions