how to use connection pooling for client in javax.

2019-02-25 18:57发布

I am trying to communicate with a server using https service

I am able to communicate but it takes 2 Secs response time..

Now, I want to reduce time for SSL handshake for every request

So, I want to cache or keep the connection live or create pooling connection..

Any suggestions..

My Code:

  static SslConfigurator sslConfig = SslConfigurator
                .newInstance()
                .securityProtocol("TLS")
                .keyStoreFile("/path")
                .keyStorePassword("password")
                .keyStoreType("JKS")
                .trustStoreFile(
                        "/path");

    static SSLContext sslCtx = sslConfig.createSSLContext();
    static Client client = ClientBuilder.newBuilder().sslContext(sslCtx).build();
    Response response = client.target(target).path(path).request(MediaType.APPLICATION_JSON)
                    .post(Entity.entity(jsonRequest.toString(), MediaType.APPLICATION_JSON));

标签: java ssl
0条回答
登录 后发表回答