Package org.springframework.data.redis.connection

Examples of org.springframework.data.redis.connection.RedisConnection


    DefaultLettucePool pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
    pool.afterPropertiesSet();
    LettuceConnectionFactory factory2 = new LettuceConnectionFactory(pool);
    factory2.setShareNativeConnection(false);
    factory2.afterPropertiesSet();
    RedisConnection connection = factory2.getConnection();
    // Use the connection to make sure the channel is initialized, else nothing happens on close
    connection.ping();
    connection.close();
    // The dedicated connection should not be closed
    connection.ping();

    connection.close();
    factory2.destroy();
    pool.destroy();
  }
View Full Code Here


  @Test
  public void testCloseNonPooledConnectionNotShared() {
    LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());
    factory2.setShareNativeConnection(false);
    factory2.afterPropertiesSet();
    RedisConnection connection = factory2.getConnection();
    // Use the connection to make sure the channel is initialized, else nothing happens on close
    connection.ping();
    connection.close();
    // The dedicated connection should be closed
    try {
      connection.set("foo".getBytes(), "bar".getBytes());
      fail("Exception should be thrown trying to use a closed connection");
    } catch (RedisSystemException e) {}
    factory2.destroy();
  }
View Full Code Here

    DefaultLettucePool pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
    pool.afterPropertiesSet();
    LettuceConnectionFactory factory2 = new LettuceConnectionFactory(pool);
    factory2.setShareNativeConnection(false);
    factory2.afterPropertiesSet();
    RedisConnection connection = factory2.getConnection();
    // Use the connection to make sure the channel is initialized, else nothing happens on close
    connection.ping();
    ((RedisAsyncConnection) connection.getNativeConnection()).close();
    try {
      connection.ping();
      fail("Exception should be thrown trying to use a closed connection");
    } catch (RedisSystemException e) {}
    connection.close();
    factory2.destroy();
    pool.destroy();
  }
View Full Code Here

    JedisConnectionFactory factory2 = new JedisConnectionFactory(config);
    factory2.setHostName(SettingsUtils.getHost());
    factory2.setPort(SettingsUtils.getPort());
    factory2.afterPropertiesSet();

    RedisConnection conn2 = factory2.getConnection();
    conn2.close();
    factory2.getConnection();
    factory2.destroy();
  }
View Full Code Here

        setDaemon(true);
      }

      public void run() {

        RedisConnection con = connectionFactory.getConnection();
        try {
          Thread.sleep(100);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }

        con.publish(expectedChannel.getBytes(), expectedMessage.getBytes());

        try {
          Thread.sleep(100);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }

        /*
           In some clients, unsubscribe happens async of message
        receipt, so not all
        messages may be received if unsubscribing now.
        Connection.close in teardown
        will take care of unsubscribing.
        */
        if (!(ConnectionUtils.isAsync(connectionFactory))) {
          connection.getSubscription().unsubscribe();
        }
        con.close();
      }
    };
    t.start();

    connection.subscribe(listener, expectedChannel.getBytes());
View Full Code Here

      }

      public void run() {

        // open a new connection
        RedisConnection con = connectionFactory.getConnection();
        try {
          Thread.sleep(100);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }

        con.publish("channel1".getBytes(), expectedMessage.getBytes());
        con.publish("channel2".getBytes(), expectedMessage.getBytes());

        try {
          Thread.sleep(100);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }

        con.close();
        // In some clients, unsubscribe happens async of message
        // receipt, so not all
        // messages may be received if unsubscribing now.
        // Connection.close in teardown
        // will take care of unsubscribing.
View Full Code Here

    factory2.setUsePool(true);
    factory2.setHostName(SettingsUtils.getHost());
    factory2.setPort(SettingsUtils.getPort());
    factory2.afterPropertiesSet();

    RedisConnection conn = factory2.getConnection();
    try {
      conn.get(null);
    } catch (Exception e) {}
    conn.close();
    // Make sure we don't end up with broken connection
    factory2.getConnection().dbSize();
    factory2.destroy();
  }
View Full Code Here

    JedisConnectionFactory factory2 = new JedisConnectionFactory(config);
    factory2.setHostName(SettingsUtils.getHost());
    factory2.setPort(SettingsUtils.getPort());
    factory2.setDatabase(1);
    factory2.afterPropertiesSet();
    RedisConnection conn2 = factory2.getConnection();
    conn2.openPipeline();
    conn2.close();
    factory2.getConnection();
    factory2.destroy();
  }
View Full Code Here

    DefaultLettucePool pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
    pool.afterPropertiesSet();
    LettuceConnectionFactory factory2 = new LettuceConnectionFactory(pool);
    factory2.setShareNativeConnection(false);
    factory2.afterPropertiesSet();
    RedisConnection connection = factory2.getConnection();
    connection.select(2);
    connection.close();
    factory2.destroy();
    pool.destroy();
  }
View Full Code Here

TOP

Related Classes of org.springframework.data.redis.connection.RedisConnection

Copyright © 2018 www.massapicom. 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.