Spring Data Key-Value

org.springframework.data.keyvalue.redis.connection
Interface RedisPubSubCommands

All Known Subinterfaces:
RedisCommands, RedisConnection, StringRedisConnection
All Known Implementing Classes:
DefaultStringRedisConnection, JedisConnection, JredisConnection

public interface RedisPubSubCommands

PubSub-specific Redis commands.

Author:
Costin Leau

Method Summary
 Subscription getSubscription()
          Returns the current subscription for this connection or null if the connection is not subscribed.
 boolean isSubscribed()
          Indicates whether the current connection is subscribed (to at least one channel) or not.
 void pSubscribe(MessageListener listener, byte[]... patterns)
          Subscribes the connection to all channels matching the given patterns.
 Long publish(byte[] channel, byte[] message)
          Publishes the given message to the given channel.
 void subscribe(MessageListener listener, byte[]... channels)
          Subscribes the connection to the given channels.
 

Method Detail

isSubscribed

boolean isSubscribed()
Indicates whether the current connection is subscribed (to at least one channel) or not.

Returns:
true if the connection is subscribed, false otherwise

getSubscription

Subscription getSubscription()
Returns the current subscription for this connection or null if the connection is not subscribed.

Returns:
the current subscription, null if none is available

publish

Long publish(byte[] channel,
             byte[] message)
Publishes the given message to the given channel.

Parameters:
channel - the channel to publish to
message - message to publish
Returns:
the number of clients that received the message

subscribe

void subscribe(MessageListener listener,
               byte[]... channels)
Subscribes the connection to the given channels. Once subscribed, a connection enters listening mode and can only subscribe to other channels or unsubscribe. No other commands are accepted until the connection is unsubscribed.

Note that this operation is blocking and the current thread starts waiting for new messages immediately.

Parameters:
listener - message listener
channels - channel names

pSubscribe

void pSubscribe(MessageListener listener,
                byte[]... patterns)
Subscribes the connection to all channels matching the given patterns. Once subscribed, a connection enters listening mode and can only subscribe to other channels or unsubscribe. No other commands are accepted until the connection is unsubscribed.

Note that this operation is blocking and the current thread starts waiting for new messages immediately.

Parameters:
listener - message listener
patterns - channel name patterns

Spring Data Key-Value

Copyright © 2010-2011 SpringSource. All Rights Reserved.