List of usage examples for org.springframework.data.redis.connection RedisConnection subscribe
void subscribe(MessageListener listener, byte[]... channels);
From source file:com.zxy.commons.cache.RedisUtils.java
/** * 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. * <p>/*from w w w . j a v a 2 s .co m*/ * Note that this operation is blocking and the current thread starts waiting for new messages immediately. * * @param listener message listener * @param channels channel names */ public static void subscribe(MessageListener listener, byte[]... channels) { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.subscribe(listener, channels); return null; } }); }
From source file:com.zxy.commons.cache.RedisHelper.java
/** * 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. * <p>//from ww w .j a v a 2 s . co m * Note that this operation is blocking and the current thread starts waiting for new messages immediately. * * @param listener message listener * @param channels channel names */ public void subscribe(MessageListener listener, byte[]... channels) { redisTemplate.execute(new RedisCallback<Void>() { @Override public Void doInRedis(RedisConnection redis) throws DataAccessException { redis.subscribe(listener, channels); return null; } }); }