Package redis.clients.jedis

Examples of redis.clients.jedis.Jedis.publish()


      long startTime = System.currentTimeMillis();
      JedisPool pool = jedisPoolMap.get(endpoint);
      Jedis connection = pool.getResource();
      String []tokens = endpoint.split("/");
      String channel = tokens[tokens.length-1];
      long numClients = connection.publish(channel, message.getMessage());
      long timeTaken = System.currentTimeMillis() - startTime;
      pool.returnResource(connection);
      logger.debug("event=send_redis endpoint="+ endpoint + " num_clients=" + numClients + " conn=reuse resp_ms=" + timeTaken);
      return;
    } else {
View Full Code Here


        String host = m.group(3);
        String port = m.group(4);
        String channel = m.group(5);
        JedisPool pool = new JedisPool( new JedisPoolConfig(), host, Integer.parseInt(port), timeoutMS, password);
        Jedis connection = pool.getResource();
        long numClients = connection.publish(channel, message.getMessage());
        long timeTaken = System.currentTimeMillis() - startTime;
        logger.debug("event=send_redis endpoint=" + endpoint + " num_clients=" + numClients + " conn=new resp_ms=" + timeTaken);
        pool.returnResource(connection);
        jedisPoolMap.put(endpoint, pool);
        return;
View Full Code Here

                Jedis jedis = jedisPool.getResource();
                try {
                    for (String provider : new HashSet<String>(getRegistered())) {
                        String key = toProviderPath(URL.valueOf(provider));
                        if (jedis.hset(key, provider, String.valueOf(System.currentTimeMillis() + expirePeriod)) == 0) {
                            jedis.publish(key, Constants.REGISTER);
                        }
                    }
                    for (String consumer : new HashSet<String>(getSubscribed().keySet())) {
                        URL url = URL.valueOf(consumer);
                        if (! Constants.ANY_VALUE.equals(url.getServiceInterface())) {
View Full Code Here

                    for (String consumer : new HashSet<String>(getSubscribed().keySet())) {
                        URL url = URL.valueOf(consumer);
                        if (! Constants.ANY_VALUE.equals(url.getServiceInterface())) {
                            String key = toConsumerPath(url);
                            if (jedis.hset(key, consumer, String.valueOf(System.currentTimeMillis() + expirePeriod)) == 0) {
                                jedis.publish(key, Constants.SUBSCRIBE);
                            }
                        }
                    }
                    if (admin) {
                        clean(jedis);
View Full Code Here

            JedisPool jedisPool = entry.getValue();
            try {
                Jedis jedis = jedisPool.getResource();
                try {
                    jedis.hset(key, value, expire);
                    jedis.publish(key, Constants.REGISTER);
                    success = true;
                } finally {
                    jedisPool.returnResource(jedis);
                }
            } catch (Throwable t) {
View Full Code Here

            JedisPool jedisPool = entry.getValue();
            try {
                Jedis jedis = jedisPool.getResource();
                try {
                    jedis.hdel(key, value);
                    jedis.publish(key, Constants.UNREGISTER);
                } finally {
                    jedisPool.returnResource(jedis);
                }
            } catch (Throwable t) {
                exception = new RpcException("Failed to unregister service to redis registry. registry: " + entry.getKey() + ", service: " + url + ", cause: " + t.getMessage(), t);
View Full Code Here

                    } else {
                        String key = toConsumerPath(url);
                        String value = url.toFullString();
                        String expire = String.valueOf(System.currentTimeMillis() + expirePeriod);
                        jedis.hset(key, value, expire);
                        jedis.publish(key, Constants.SUBSCRIBE);
                        doNotify(jedis, service, url, listener);
                    }
                    success = true;
                    break; // 只需读一个服务器的数据
                } finally {
View Full Code Here

                JedisPool jedisPool = entry.getValue();
                try {
                    Jedis jedis = jedisPool.getResource();
                    try {
                        jedis.hdel(key, value);
                        jedis.publish(key, Constants.UNSUBSCRIBE);
                    } finally {
                        jedisPool.returnResource(jedis);
                    }
                } catch (Throwable t) {
                    exception = new RpcException("Failed to unsubscribe service to redis registry. registry: " + entry.getKey() + ", service: " + url + ", cause: " + t.getMessage(), t);
View Full Code Here

            try {
                RedisSessionEvent redisSessionEvent = new RedisSessionCreatedEvent(id);
                byte[] bytes = RedisSerializationUtil.encode(redisSessionEvent);
                String message = new String(Base64Util.encode(bytes));

                jedis.publish(RedisSessionKeys.getSessionChannel(), message);

                log.debug("Sended " + redisSessionEvent.toString());

                pool.returnResource(jedis);
            } catch (Throwable e) {
View Full Code Here

            jedis = pool.getResource();
            try {
                bytes = RedisSerializationUtil.encode(sessionEvent);
                String message = new String(Base64Util.encode(bytes));

                jedis.publish(RedisSessionKeys.getSessionChannel(), message);

                log.debug("Sended " + sessionEvent.toString());

                pool.returnResource(jedis);
            } catch (Throwable e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.