Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mp911de opened this issue Apr 26, 2021 · 1 comment

Comments

@mp911de
Copy link
Member

mp911de commented Apr 26, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment