Class HttpTransportClient

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    HttpsTransportClient

    public class HttpTransportClient
    extends TransportClient
    CloseableHttpAsyncClient based TransportClient implementation.
    • Constructor Summary

      Constructors 
      Constructor Description
      HttpTransportClient​(java.lang.String routerUrl, int maxConnectionsTotal, int maxConnectionsPerRoute)  
      HttpTransportClient​(java.lang.String routerUrl, org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient httpClient)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected static org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient buildClient​(java.lang.String routerUrl, int maxConnectionsTotal, int maxConnectionsPerRoute, boolean requireHHtp2, SSLFactory sslFactory)
      Note: The callback that is triggered by CloseableHttpAsyncClient runs in the same thread as one of it's worker threads and if the users of the future run tasks that block the release of the future thread, a deadlock will occur.
      void close()  
      java.util.concurrent.CompletableFuture<TransportClientResponse> get​(java.lang.String requestPath, java.util.Map<java.lang.String,​java.lang.String> headers)  
      TransportClient getCopyIfNotUsableInCallback()
      The same CloseableHttpAsyncClient could not be used to send out another request in its own callback function.
      int getMaxConnectionsPerRoute()  
      int getMaxConnectionsTotal()  
      java.util.concurrent.CompletableFuture<TransportClientResponse> post​(java.lang.String requestPath, java.util.Map<java.lang.String,​java.lang.String> headers, byte[] requestBody)
      Note: The callback that is triggered by CloseableHttpAsyncClient runs in the same thread as one of it's worker threads and if the users of the future run tasks that block the release of the future thread, a deadlock will occur.
      void streamPost​(java.lang.String requestPath, java.util.Map<java.lang.String,​java.lang.String> headers, byte[] requestBody, TransportClientStreamingCallback callback, int keyCount)
      Leverage non-streaming post to achieve feature parity.
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • routerUrl

        protected final java.lang.String routerUrl
      • maxConnectionsTotal

        protected int maxConnectionsTotal
      • maxConnectionsPerRoute

        protected int maxConnectionsPerRoute
    • Constructor Detail

      • HttpTransportClient

        public HttpTransportClient​(java.lang.String routerUrl,
                                   int maxConnectionsTotal,
                                   int maxConnectionsPerRoute)
      • HttpTransportClient

        public HttpTransportClient​(java.lang.String routerUrl,
                                   org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient httpClient)
    • Method Detail

      • buildClient

        protected static org.apache.hc.client5.http.impl.async.CloseableHttpAsyncClient buildClient​(java.lang.String routerUrl,
                                                                                                    int maxConnectionsTotal,
                                                                                                    int maxConnectionsPerRoute,
                                                                                                    boolean requireHHtp2,
                                                                                                    SSLFactory sslFactory)
        Note: The callback that is triggered by CloseableHttpAsyncClient runs in the same thread as one of it's worker threads and if the users of the future run tasks that block the release of the future thread, a deadlock will occur. Hence, use the async handlers of CompletableFuture if you plan to use the same client to make multiple requests sequentially.
      • get

        public java.util.concurrent.CompletableFuture<TransportClientResponse> get​(java.lang.String requestPath,
                                                                                   java.util.Map<java.lang.String,​java.lang.String> headers)
        Specified by:
        get in class TransportClient
      • post

        public java.util.concurrent.CompletableFuture<TransportClientResponse> post​(java.lang.String requestPath,
                                                                                    java.util.Map<java.lang.String,​java.lang.String> headers,
                                                                                    byte[] requestBody)
        Note: The callback that is triggered by CloseableHttpAsyncClient runs in the same thread as one of it's worker threads and if the users of the future run tasks that block the release of the future thread, a deadlock will occur. Hence, use the async handlers of CompletableFuture if you plan to use the same client to make multiple requests sequentially.
        Specified by:
        post in class TransportClient
      • streamPost

        public void streamPost​(java.lang.String requestPath,
                               java.util.Map<java.lang.String,​java.lang.String> headers,
                               byte[] requestBody,
                               TransportClientStreamingCallback callback,
                               int keyCount)
        Leverage non-streaming post to achieve feature parity. Note: The callback that is triggered by CloseableHttpAsyncClient runs in the same thread as one of it's worker threads and if the users of the future run tasks that block the release of the future thread, a deadlock will occur. Hence, use the async handlers of CompletableFuture if you plan to use the same client to make multiple requests sequentially.
        Specified by:
        streamPost in class TransportClient
      • close

        public void close()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • getMaxConnectionsTotal

        public int getMaxConnectionsTotal()
      • getMaxConnectionsPerRoute

        public int getMaxConnectionsPerRoute()