Interface Subscription
- All Known Implementing Classes:
AbstractSubscription
,LettuceSubscription
public interface Subscription
Subscription for Redis channels. Just like the underlying
RedisConnection
, it should not be used by multiple
threads. Note that once a subscription died, it cannot accept any more subscriptions.- Author:
- Costin Leau, Christoph Strobl
-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Shutdown the subscription and free any resources held.Collection<byte[]>
Returns the (named) channels for this subscription.Returns the listener used for this subscription.Collection<byte[]>
Returns the channel patters for this subscription.boolean
isAlive()
Indicates whether this subscription is still 'alive' or not.void
pSubscribe
(byte[]... patterns) Adds the given channel patterns to the current subscription.void
Cancels the subscription for all channels matched by patterns.void
pUnsubscribe
(byte[]... patterns) Cancels the subscription for all channels matching the given patterns.void
subscribe
(byte[]... channels) Adds the given channels to the current subscription.void
Cancels the current subscription for all channels given by name.void
unsubscribe
(byte[]... channels) Cancels the current subscription for all given channels.
-
Method Details
-
subscribe
Adds the given channels to the current subscription.- Parameters:
channels
- channel names. Must not be empty.- Throws:
RedisInvalidSubscriptionException
-
pSubscribe
Adds the given channel patterns to the current subscription.- Parameters:
patterns
- channel patterns. Must not be empty.- Throws:
RedisInvalidSubscriptionException
-
unsubscribe
void unsubscribe()Cancels the current subscription for all channels given by name. -
unsubscribe
void unsubscribe(byte[]... channels) Cancels the current subscription for all given channels.- Parameters:
channels
- channel names. Must not be empty.
-
pUnsubscribe
void pUnsubscribe()Cancels the subscription for all channels matched by patterns. -
pUnsubscribe
void pUnsubscribe(byte[]... patterns) Cancels the subscription for all channels matching the given patterns.- Parameters:
patterns
- must not be empty.
-
getChannels
Collection<byte[]> getChannels()Returns the (named) channels for this subscription.- Returns:
- collection of named channels
-
getPatterns
Collection<byte[]> getPatterns()Returns the channel patters for this subscription.- Returns:
- collection of channel patterns
-
getListener
MessageListener getListener()Returns the listener used for this subscription.- Returns:
- the listener used for this subscription.
-
isAlive
boolean isAlive()Indicates whether this subscription is still 'alive' or not.- Returns:
- true if the subscription still applies, false otherwise.
-
close
void close()Shutdown the subscription and free any resources held.- Since:
- 1.8.12
-