public class RedisPubSubConnection<K,V> extends RedisAsyncConnection<K,V>
RedisAsyncConnection.quit()
may be called.
Incoming messages and results of the subscribe(java.lang.String...)
/unsubscribe(java.lang.String...)
calls will be passed to all registered RedisPubSubListener
s.
A ConnectionWatchdog
monitors each
connection and reconnects automatically until RedisAsyncConnection.close()
is called. Channel
and pattern subscriptions are renewed after reconnecting.Constructor and Description |
---|
RedisPubSubConnection(RedisClient client,
BlockingQueue<Command<K,V,?>> queue,
RedisCodec<K,V> codec,
long timeout,
TimeUnit unit,
io.netty.channel.EventLoopGroup eventLoopGroup)
Initialize a new connection.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(RedisPubSubListener<V> listener)
Add a new listener.
|
void |
channelActive(io.netty.channel.ChannelHandlerContext ctx) |
void |
channelRead(io.netty.channel.ChannelHandlerContext ctx,
Object msg) |
void |
psubscribe(String... patterns) |
void |
punsubscribe(String... patterns) |
void |
removeListener(RedisPubSubListener<V> listener)
Remove an existing listener.
|
void |
subscribe(String... channels) |
void |
unsubscribe(String... channels) |
append, auth, await, awaitAll, awaitAll, bgrewriteaof, bgsave, bitcount, bitcount, bitopAnd, bitopNot, bitopOr, bitopXor, blpop, brpop, brpoplpush, channelInactive, clientGetname, clientKill, clientList, clientSetname, close, configGet, configResetstat, configSet, dbsize, debugObject, decr, decrby, del, digest, discard, dispatch, dispatch, dispatch, dispatch, dispatch, dump, echo, eval, evalsha, exec, exists, expire, expireat, expireat, flushall, flushdb, get, getbit, getMasterAddrByKey, getrange, getRedisClient, getset, hdel, hexists, hget, hgetall, hincrby, hincrbyfloat, hkeys, hlen, hmget, hmset, hset, hsetnx, hvals, incr, incrby, incrbyfloat, info, info, isMultiMode, keys, lastsave, lindex, linsert, llen, lpop, lpush, lpushx, lrange, lrem, lset, ltrim, mget, migrate, move, mset, msetnx, multi, newScriptOutput, objectEncoding, objectIdletime, objectRefcount, persist, pexpire, pexpireat, pexpireat, pfadd, pfcount, pfmerge, ping, pttl, publish, quit, randomkey, rename, renamenx, restore, rpop, rpoplpush, rpush, rpushx, sadd, save, scard, scriptExists, scriptFlush, scriptKill, scriptLoad, sdiff, sdiffstore, select, set, setbit, setex, setnx, setrange, setTimeout, shutdown, shutdown, sinter, sinterstore, sismember, slaveof, slaveofNoOne, slaves, slowlogGet, slowlogGet, slowlogLen, slowlogReset, smembers, smove, sort, sort, sortStore, spop, srandmember, srandmember, srem, sscan, string, strlen, sunion, sunionstore, sync, ttl, type, unwatch, watch, zadd, zadd, zcard, zcount, zcount, zincrby, zinterstore, zinterstore, zrange, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscore, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangebyscoreWithScores, zrangeWithScores, zrank, zrem, zremrangebyrank, zremrangebyscore, zremrangebyscore, zrevrange, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscore, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangebyscoreWithScores, zrevrangeWithScores, zrevrank, zscan, zscore, zunionstore, zunionstore
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, exceptionCaught, userEventTriggered
handlerAdded, handlerRemoved, isSharable
public RedisPubSubConnection(RedisClient client, BlockingQueue<Command<K,V,?>> queue, RedisCodec<K,V> codec, long timeout, TimeUnit unit, io.netty.channel.EventLoopGroup eventLoopGroup)
queue
- Command queue.codec
- Codec used to encode/decode keys and values.timeout
- Maximum time to wait for a responses.unit
- Unit of time for the timeout.eventLoopGroup
- public void addListener(RedisPubSubListener<V> listener)
listener
- Listener.public void removeListener(RedisPubSubListener<V> listener)
listener
- Listener.public void psubscribe(String... patterns)
public void punsubscribe(String... patterns)
public void subscribe(String... channels)
public void unsubscribe(String... channels)
public void channelActive(io.netty.channel.ChannelHandlerContext ctx) throws Exception
channelActive
in interface io.netty.channel.ChannelInboundHandler
channelActive
in class RedisAsyncConnection<K,V>
Exception
Copyright © 2014. All rights reserved.