DATAKV-22
+ pass initial channels and patterns through constructor
This commit is contained in:
@@ -1619,7 +1619,7 @@ public class JedisConnection implements RedisConnection {
|
||||
String[] pats = JedisUtils.convert(patterns);
|
||||
JedisPubSub jedisPubSub = JedisUtils.adaptPubSub(listener);
|
||||
|
||||
subscription = new JedisSubscription(listener, jedisPubSub);
|
||||
subscription = new JedisSubscription(listener, jedisPubSub, null, patterns);
|
||||
jedis.psubscribe(jedisPubSub, pats);
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
@@ -1641,7 +1641,7 @@ public class JedisConnection implements RedisConnection {
|
||||
String[] chs = JedisUtils.convert(channels);
|
||||
JedisPubSub jedisPubSub = JedisUtils.adaptPubSub(listener);
|
||||
|
||||
subscription = new JedisSubscription(listener, jedisPubSub);
|
||||
subscription = new JedisSubscription(listener, jedisPubSub, channels, null);
|
||||
jedis.subscribe(jedisPubSub, chs);
|
||||
} catch (Exception ex) {
|
||||
throw convertJedisAccessException(ex);
|
||||
|
||||
@@ -38,10 +38,22 @@ class JedisSubscription implements Subscription {
|
||||
private final Collection<byte[]> channels = new ArrayList<byte[]>(2);
|
||||
private final Collection<byte[]> patterns = new ArrayList<byte[]>(2);
|
||||
|
||||
JedisSubscription(MessageListener listener, JedisPubSub jedisPubSub) {
|
||||
JedisSubscription(MessageListener listener, JedisPubSub jedisPubSub, byte[][] channels, byte[][] patterns) {
|
||||
Assert.notNull(listener);
|
||||
this.listener = listener;
|
||||
this.jedisPubSub = jedisPubSub;
|
||||
|
||||
if (!ObjectUtils.isArray(channels)) {
|
||||
for (byte[] bs : channels) {
|
||||
this.channels.add(bs);
|
||||
}
|
||||
}
|
||||
|
||||
if (!ObjectUtils.isArray(patterns)) {
|
||||
for (byte[] bs : patterns) {
|
||||
this.patterns.add(bs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user