Пример #1
0
 public static RemotingClient createRemotingClient() {
   NettyClientConfig config = new NettyClientConfig();
   config.setClientChannelMaxIdleTimeSeconds(15);
   RemotingClient client = new NettyRemotingClient(config);
   client.start();
   return client;
 }
Пример #2
0
  // @Test
  public void test_idle_event()
      throws InterruptedException, RemotingConnectException, RemotingSendRequestException,
          RemotingTimeoutException {
    RemotingServer server = createRemotingServer();
    RemotingClient client = createRemotingClient();

    for (int i = 0; i < 10; i++) {
      RemotingCommand request = RemotingCommand.createRequestCommand(0, null);
      RemotingCommand response = client.invokeSync("localhost:8888", request, 1000 * 3);
      System.out.println(i + " invoke result = " + response);
      assertTrue(response != null);

      Thread.sleep(1000 * 10);
    }

    Thread.sleep(1000 * 60);

    client.shutdown();
    server.shutdown();
    System.out.println("-----------------------------------------------------------------");
  }