@Test(expected = JedisConnectionException.class) public void unsubscribeWhenNotSusbscribed() throws InterruptedException { JedisPubSub pubsub = new JedisPubSub() { public void onMessage(String channel, String message) {} public void onPMessage(String pattern, String channel, String message) {} public void onSubscribe(String channel, int subscribedChannels) {} public void onUnsubscribe(String channel, int subscribedChannels) {} public void onPUnsubscribe(String pattern, int subscribedChannels) {} public void onPSubscribe(String pattern, int subscribedChannels) {} }; pubsub.unsubscribe(); }
/** Interrupt the thread and stop the blocking subscription. */ private void shutdown() { running.getAndSet(false); this.interrupt(); try { if (subscriber != null) { subscriber.unsubscribe(); } } finally { JedisUtils.closeJedis(sentinelJedis); } }
@Override public void onPSubscribe(String pattern, int subscribedChannels) { setReady(); super.onPSubscribe(pattern, subscribedChannels); }
@Override public void onSubscribe(String channel, int subscribedChannels) { setReady(); super.onSubscribe(channel, subscribedChannels); }
public void psubscribe(JedisPubSub jedisPubSub, String... patterns) { client.setTimeoutInfinite(); jedisPubSub.proceedWithPatterns(client, patterns); client.rollbackTimeout(); }
public void subscribe(JedisPubSub jedisPubSub, String... channels) { client.setTimeoutInfinite(); jedisPubSub.proceed(client, channels); client.rollbackTimeout(); }