@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();
  }
Пример #2
0
    /** 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);
 }
Пример #5
0
 public void psubscribe(JedisPubSub jedisPubSub, String... patterns) {
   client.setTimeoutInfinite();
   jedisPubSub.proceedWithPatterns(client, patterns);
   client.rollbackTimeout();
 }
Пример #6
0
 public void subscribe(JedisPubSub jedisPubSub, String... channels) {
   client.setTimeoutInfinite();
   jedisPubSub.proceed(client, channels);
   client.rollbackTimeout();
 }