Example usage for org.springframework.data.redis.connection.jedis JedisSubscription JedisSubscription

List of usage examples for org.springframework.data.redis.connection.jedis JedisSubscription JedisSubscription

Introduction

In this page you can find the example usage for org.springframework.data.redis.connection.jedis JedisSubscription JedisSubscription.

Prototype

JedisSubscription(MessageListener listener, BinaryJedisPubSub jedisPubSub, @Nullable byte[][] channels,
            @Nullable byte[][] patterns) 

Source Link

Usage

From source file:org.springframework.data.redis.connection.jedis.JedisClusterConnection.java

@Override
public void subscribe(MessageListener listener, byte[]... channels) {

    if (isSubscribed()) {
        throw new RedisSubscribedConnectionException(
                "Connection already subscribed; use the connection Subscription to cancel or add new channels");
    }/*from w  w w  .  j av  a  2  s.c  om*/
    try {
        BinaryJedisPubSub jedisPubSub = new JedisMessageListener(listener);
        subscription = new JedisSubscription(listener, jedisPubSub, channels, null);
        cluster.subscribe(jedisPubSub, channels);
    } catch (Exception ex) {
        throw convertJedisAccessException(ex);
    }
}

From source file:org.springframework.data.redis.connection.jedis.JedisClusterConnection.java

@Override
public void pSubscribe(MessageListener listener, byte[]... patterns) {

    if (isSubscribed()) {
        throw new RedisSubscribedConnectionException(
                "Connection already subscribed; use the connection Subscription to cancel or add new channels");
    }//from  w  w w.  j a va 2 s.  co  m
    try {
        BinaryJedisPubSub jedisPubSub = new JedisMessageListener(listener);
        subscription = new JedisSubscription(listener, jedisPubSub, null, patterns);
        cluster.psubscribe(jedisPubSub, patterns);
    } catch (Exception ex) {
        throw convertJedisAccessException(ex);
    }
}