public abstract class AbstractSubscription extends Object implements Subscription
Modifier | Constructor and Description |
---|---|
protected |
AbstractSubscription(MessageListener listener) |
protected |
AbstractSubscription(MessageListener listener,
byte[][] channels,
byte[][] patterns)
Constructs a new
AbstractSubscription instance. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Shutdown the subscription and free any resources held.
|
protected abstract void |
doClose()
Shutdown the subscription and free any resources held.
|
protected abstract void |
doPsubscribe(byte[]... patterns)
Subscribe to the given patterns
|
protected abstract void |
doPUnsubscribe(boolean all,
byte[]... patterns)
Pattern unsubscribe.
|
protected abstract void |
doSubscribe(byte[]... channels)
Subscribe to the given channels.
|
protected abstract void |
doUnsubscribe(boolean all,
byte[]... channels)
Channel unsubscribe.
|
Collection<byte[]> |
getChannels()
Returns the (named) channels for this subscription.
|
MessageListener |
getListener()
Returns the listener used for this subscription.
|
Collection<byte[]> |
getPatterns()
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 |
pUnsubscribe()
Cancels the subscription for all channels matched by patterns.
|
void |
pUnsubscribe(byte[]... patts)
Cancels the subscription for all channels matching the given patterns.
|
void |
subscribe(byte[]... channels)
Adds the given channels to the current subscription.
|
void |
unsubscribe()
Cancels the current subscription for all channels given by name.
|
void |
unsubscribe(byte[]... chans)
Cancels the current subscription for all given channels.
|
protected AbstractSubscription(MessageListener listener)
protected AbstractSubscription(MessageListener listener, @Nullable byte[][] channels, @Nullable byte[][] patterns)
AbstractSubscription
instance. Allows channels and patterns to be added to the
subscription w/o triggering a subscription action (as some clients (Jedis) require an initial call before entering
into listening mode).listener
- must not be null.channels
- can be null.patterns
- can be null.protected abstract void doSubscribe(byte[]... channels)
channels
- channels to subscribe toprotected abstract void doUnsubscribe(boolean all, byte[]... channels)
all
- true if all the channels are unsubscribed (used as a hint for the underlying implementation).channels
- channels to be unsubscribedprotected abstract void doPsubscribe(byte[]... patterns)
patterns
- patterns to subscribe toprotected abstract void doPUnsubscribe(boolean all, byte[]... patterns)
all
- true if all the patterns are unsubscribed (used as a hint for the underlying implementation).patterns
- patterns to be unsubscribedpublic void close()
Subscription
close
in interface Subscription
protected abstract void doClose()
public MessageListener getListener()
Subscription
getListener
in interface Subscription
public Collection<byte[]> getChannels()
Subscription
getChannels
in interface Subscription
public Collection<byte[]> getPatterns()
Subscription
getPatterns
in interface Subscription
public void pSubscribe(byte[]... patterns)
Subscription
pSubscribe
in interface Subscription
patterns
- channel patterns. Must not be empty.public void pUnsubscribe()
Subscription
pUnsubscribe
in interface Subscription
public void subscribe(byte[]... channels)
Subscription
subscribe
in interface Subscription
channels
- channel names. Must not be empty.public void unsubscribe()
Subscription
unsubscribe
in interface Subscription
public void pUnsubscribe(@Nullable byte[]... patts)
Subscription
pUnsubscribe
in interface Subscription
patts
- must not be empty.public void unsubscribe(@Nullable byte[]... chans)
Subscription
unsubscribe
in interface Subscription
chans
- channel names. Must not be empty.public boolean isAlive()
Subscription
isAlive
in interface Subscription
Copyright © 2011–2020 Pivotal Software, Inc.. All rights reserved.