redis.clients.jedis.Jedis.subscribe()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(4.5k)|赞(0)|评价(0)|浏览(223)

本文整理了Java中redis.clients.jedis.Jedis.subscribe()方法的一些代码示例,展示了Jedis.subscribe()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Jedis.subscribe()方法的具体详情如下:
包路径:redis.clients.jedis.Jedis
类名称:Jedis
方法名:subscribe

Jedis.subscribe介绍

暂无

代码示例

代码示例来源:origin: sohutv/cachecloud

@Override
 public Integer execute(Jedis connection) {
  connection.subscribe(jedisPubSub, patterns);
  return 0;
 }
}.runWithAnyNode();

代码示例来源:origin: sohutv/cachecloud

@Override
 public Integer execute(Jedis connection) {
  connection.subscribe(jedisPubSub, channels);
  return 0;
 }
}.runWithAnyNode();

代码示例来源:origin: sohutv/cachecloud

@Override
 public Integer execute(Jedis connection) {
  connection.subscribe(jedisPubSub, patterns);
  return 0;
 }
}.runWithAnyNode();

代码示例来源:origin: sohutv/cachecloud

@Override
 public Integer execute(Jedis connection) {
  connection.subscribe(jedisPubSub, channels);
  return 0;
 }
}.runWithAnyNode();

代码示例来源:origin: sohutv/cachecloud

j.subscribe(new JedisPubSub() {
 @Override
 public void onMessage(String channel, String message) {

代码示例来源:origin: sohutv/cachecloud

/**
 * 订阅单一频道(阻塞操作)
 *
 * @param jedisPubSub
 * @param channel
 */
public void subscribe(final JedisPubSub jedisPubSub, final String channel, final int timeout) {
  SubPubClusterCommand subPubClusterCommand = new SubPubClusterCommand(this, connectionHandler, maxRedirections);
  Jedis jedis = subPubClusterCommand.getNewJedis(channel, timeout);
  try {
    jedis.subscribe(jedisPubSub, channel);
  } finally {
    if (jedis != null) {
      jedis.close();
    }
  }
}

代码示例来源:origin: ltsopensource/light-task-scheduler

jedis.subscribe(new NotifySub(jedisPool), listenNodePath); // 阻塞
  break;
} finally {

代码示例来源:origin: ltsopensource/light-task-scheduler

jedis.subscribe(new NotifySub(jedisPool), listenNodePath); // 阻塞
  break;
} finally {

代码示例来源:origin: spring-projects/spring-data-redis

@Override
public void subscribe(MessageListener listener, byte[]... channels) {
  if (isSubscribed()) {
    throw new RedisSubscribedConnectionException(
        "Connection already subscribed; use the connection Subscription to cancel or add new channels");
  }
  if (isQueueing()) {
    throw new UnsupportedOperationException();
  }
  if (isPipelined()) {
    throw new UnsupportedOperationException();
  }
  try {
    BinaryJedisPubSub jedisPubSub = new JedisMessageListener(listener);
    subscription = new JedisSubscription(listener, jedisPubSub, channels, null);
    jedis.subscribe(jedisPubSub, channels);
  } catch (Exception ex) {
    throw convertJedisAccessException(ex);
  }
}

代码示例来源:origin: gresrun/jesque

/**
   * {@inheritDoc}
   */
  @Override
  public Void doWork(final Jedis jedis) {
    jedis.subscribe(jedisPubSub, createFullChannels());
    return null;
  }
});

代码示例来源:origin: io.leopard/leopard-redis

@Override
  public Object execute(Jedis jedis) {
    jedis.subscribe(jedisPubSub, channels);
    return null;
  }
});

代码示例来源:origin: apache/servicemix-bundles

@Override
 public Integer execute(Jedis connection) {
  connection.subscribe(jedisPubSub, channels);
  return 0;
 }
}.runWithAnyNode();

代码示例来源:origin: lindzh/hasting

@Override
  public void run() {
    logger.info("subscribe:"+channel);
    jedis.subscribe(this, channel);
  }
}

代码示例来源:origin: stackoverflow.com

new Thread(new Runnable() {
   @Override
   public void run() {
     Jedis subscriberJedis = new Jedis("localhost");
     try {
       subscriberJedis.subscribe(new JedisPubSub() …..,"CC");
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
 }).start();

代码示例来源:origin: ysrc/Liudao

@Override
  public Object doInRedis(RedisConnection connection) throws DataAccessException {
    ((Jedis) connection.getNativeConnection()).subscribe(jedisPubSub, channels);
    return null;
  }
});

代码示例来源:origin: org.nuxeo.runtime/nuxeo-runtime-redis

/**
 * Run a subscriber, do not return.
 */
default void subscribe(JedisPubSub subscriber, String channel) throws JedisException {
  execute(jedis -> {
    jedis.subscribe(subscriber, channel);
    return null;
  });
}

代码示例来源:origin: io.enoa/nosql-redis

default void subscribe(JedisPubSub jedisPubSub, String... channels) {
 this.run((jedis, serializer) -> {
  jedis.subscribe(jedisPubSub, channels);
  return this;
 });
}

代码示例来源:origin: com.github.biezhi/unique-support-redis

@Override
  Object execute() {
    Jedis _jedis = jedis.getShard(channel);
    // 注意subscribe是一个阻塞操作,因为当前线程要轮询Redis的响应然后调用subscribe
    _jedis.subscribe(jedisPubSub, channel);
    return null;
  }
}.getResult();

代码示例来源:origin: vakinge/jeesuite-libs

@Override
  public void run() {
    subClient = getRedisClient();
    subClient.subscribe(new LockStateListener(), new String[]{channelName});
  }
}, channelName);

代码示例来源:origin: CoinbaseWallet/toshi-headless-client

@Override
  public void run() {
    Jedis subscriberJedis = new Jedis(config.getRedis().getUri());
    try {
      subscriberJedis.subscribe(subscriber, wallet.getOwnerAddress(), wallet.getOwnerAddress() + "_rpc_request");
      System.out.println("Subscription ended.");
    } catch (Exception e) {
      logger.log(Level.SEVERE, "Subscribing failed.", e);
    }
  }
}).start();

相关文章

Jedis类方法