Class HttpEndpoint

  • All Implemented Interfaces:
    AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.cloud.DiscoverableService, org.apache.camel.Endpoint, org.apache.camel.IsSingleton, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasId, org.apache.camel.spi.HeaderFilterStrategyAware, org.apache.camel.StatefulService, org.apache.camel.SuspendableService

    @UriEndpoint(firstVersion="2.3.0",
                 scheme="http,https",
                 title="HTTP,HTTPS",
                 syntax="http:httpUri",
                 producerOnly=true,
                 category=HTTP,
                 lenientProperties=true)
    @ManagedResource(description="Managed HttpEndpoint")
    public class HttpEndpoint
    extends org.apache.camel.http.common.HttpCommonEndpoint
    Send requests to external HTTP servers using Apache HTTP Client 4.x.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected org.apache.camel.support.jsse.SSLContextParameters sslContextParameters  
      • Fields inherited from class org.apache.camel.support.service.BaseService

        BUILDED, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTINGDOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.apache.camel.Consumer createConsumer​(org.apache.camel.Processor processor)  
      protected org.apache.http.client.HttpClient createHttpClient()
      Factory method to create a new HttpClient instance
      org.apache.camel.PollingConsumer createPollingConsumer()  
      org.apache.camel.Producer createProducer()  
      protected void doStop()  
      org.apache.http.impl.client.HttpClientBuilder getClientBuilder()  
      org.apache.http.conn.HttpClientConnectionManager getClientConnectionManager()  
      int getClientConnectionsPoolStatsAvailable()  
      int getClientConnectionsPoolStatsLeased()  
      int getClientConnectionsPoolStatsMax()  
      int getClientConnectionsPoolStatsPending()  
      HttpComponent getComponent()  
      long getConnectionRequestTimeout()  
      int getConnectionsPerRoute()  
      long getConnectTimeout()  
      org.apache.http.client.CookieStore getCookieStore()  
      String getCustomHostHeader()  
      org.apache.http.client.HttpClient getHttpClient()  
      HttpClientConfigurer getHttpClientConfigurer()  
      Map<String,​Object> getHttpClientOptions()  
      org.apache.http.protocol.HttpContext getHttpContext()  
      int getMaxTotalConnections()  
      long getSocketTimeout()  
      org.apache.camel.support.jsse.SSLContextParameters getSslContextParameters()  
      HostnameVerifier getX509HostnameVerifier()  
      boolean isAuthenticationPreemptive()  
      boolean isClearExpiredCookies()  
      boolean isDeleteWithBody()  
      boolean isGetWithBody()  
      boolean isUseSystemProperties()  
      void setAuthenticationPreemptive​(boolean authenticationPreemptive)
      If this option is true, camel-http sends preemptive basic authentication to the server.
      void setClearExpiredCookies​(boolean clearExpiredCookies)
      Whether to clear expired cookies before sending the HTTP request.
      void setClientBuilder​(org.apache.http.impl.client.HttpClientBuilder clientBuilder)
      Provide access to the http client request parameters used on new RequestConfig instances used by producers or consumers of this endpoint.
      void setClientConnectionManager​(org.apache.http.conn.HttpClientConnectionManager clientConnectionManager)
      To use a custom HttpClientConnectionManager to manage connections
      void setConnectionRequestTimeout​(long connectionRequestTimeout)
      The timeout in milliseconds used when requesting a connection from the connection manager.
      void setConnectionsPerRoute​(int connectionsPerRoute)
      The maximum number of connections per route.
      void setConnectTimeout​(long connectTimeout)
      Determines the timeout in milliseconds until a connection is established.
      void setCookieHandler​(org.apache.camel.http.base.cookie.CookieHandler cookieHandler)  
      void setCookieStore​(org.apache.http.client.CookieStore cookieStore)
      To use a custom CookieStore.
      void setCustomHostHeader​(String customHostHeader)
      Defines a custom host header which will be sent when producing http request.
      void setDeleteWithBody​(boolean deleteWithBody)
      Whether the HTTP DELETE should include the message body or not.
      void setGetWithBody​(boolean getWithBody)
      Whether the HTTP GET should include the message body or not.
      void setHttpClient​(org.apache.http.client.HttpClient httpClient)
      Sets a custom HttpClient to be used by the producer
      void setHttpClientConfigurer​(HttpClientConfigurer httpClientConfigurer)
      Register a custom configuration strategy for new HttpClient instances created by producers or consumers such as to configure authentication mechanisms etc
      void setHttpClientOptions​(Map<String,​Object> httpClientOptions)
      To configure the HttpClient using the key/values from the Map.
      void setHttpContext​(org.apache.http.protocol.HttpContext httpContext)
      To use a custom HttpContext instance
      void setMaxTotalConnections​(int maxTotalConnections)
      The maximum number of connections.
      void setSocketTimeout​(long socketTimeout)
      Defines the socket timeout (SO_TIMEOUT) in milliseconds, which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets).
      void setSslContextParameters​(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters)
      To configure security using SSLContextParameters.
      void setUseSystemProperties​(boolean useSystemProperties)
      To use System Properties as fallback for configuration
      void setX509HostnameVerifier​(HostnameVerifier x509HostnameVerifier)
      To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier.
      • Methods inherited from class org.apache.camel.http.common.HttpCommonEndpoint

        canConnect, connect, disconnect, getAuthDomain, getAuthHost, getAuthMethod, getAuthMethodPriority, getAuthPassword, getAuthUsername, getBinding, getCookieHandler, getHeaderFilterStrategy, getHttpBinding, getHttpMethod, getHttpMethodRestrict, getHttpUri, getOkStatusCodeRange, getPath, getPort, getProtocol, getProxyAuthDomain, getProxyAuthHost, getProxyAuthMethod, getProxyAuthPassword, getProxyAuthPort, getProxyAuthScheme, getProxyAuthUsername, getProxyHost, getProxyPort, getResponseBufferSize, getServiceProperties, isAsync, isBridgeEndpoint, isChunked, isConnectionClose, isCopyHeaders, isDisableStreamCache, isEagerCheckContentAvailable, isIgnoreResponseBody, isLenientProperties, isMapHttpMessageBody, isMapHttpMessageFormUrlEncodedBody, isMapHttpMessageHeaders, isMatchOnUriPrefix, isMuteException, isOptionsEnabled, isPreserveHostHeader, isThrowExceptionOnFailure, isTraceEnabled, isTransferException, setAsync, setAuthDomain, setAuthHost, setAuthMethod, setAuthMethodPriority, setAuthPassword, setAuthUsername, setBinding, setBridgeEndpoint, setChunked, setConnectionClose, setCopyHeaders, setDisableStreamCache, setEagerCheckContentAvailable, setHeaderFilterStrategy, setHttpBinding, setHttpMethod, setHttpMethodRestrict, setHttpUri, setIgnoreResponseBody, setMapHttpMessageBody, setMapHttpMessageFormUrlEncodedBody, setMapHttpMessageHeaders, setMatchOnUriPrefix, setMuteException, setOkStatusCodeRange, setOptionsEnabled, setPreserveHostHeader, setProxyAuthDomain, setProxyAuthHost, setProxyAuthMethod, setProxyAuthPassword, setProxyAuthPort, setProxyAuthScheme, setProxyAuthUsername, setProxyHost, setProxyPort, setResponseBufferSize, setThrowExceptionOnFailure, setTraceEnabled, setTransferException
      • Methods inherited from class org.apache.camel.support.DefaultEndpoint

        configureConsumer, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, doInit, doStart, equals, getCamelContext, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isBasicPropertyBinding, isBridgeErrorHandler, isLazyStartProducer, isPollingConsumerBlockWhenFull, isSingleton, isSynchronous, setBasicPropertyBinding, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerQueueSize, setProperties, setSynchronous, toString
      • Methods inherited from class org.apache.camel.support.service.BaseService

        build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspend
      • Methods inherited from interface org.apache.camel.Endpoint

        getEndpointBaseUri, isSingletonProducer
      • Methods inherited from interface org.apache.camel.Service

        build, close, init, start, stop
      • Methods inherited from interface org.apache.camel.ShutdownableService

        shutdown
      • Methods inherited from interface org.apache.camel.StatefulService

        getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspending
      • Methods inherited from interface org.apache.camel.SuspendableService

        isSuspended, resume, suspend
    • Field Detail

      • sslContextParameters

        @UriParam(label="security",
                  description="To configure security using SSLContextParameters. Important: Only one instance of org.apache.camel.util.jsse.SSLContextParameters is supported per HttpComponent. If you need to use 2 or more different instances, you need to define a new HttpComponent per instance you need.")
        protected org.apache.camel.support.jsse.SSLContextParameters sslContextParameters
    • Method Detail

      • createProducer

        public org.apache.camel.Producer createProducer()
                                                 throws Exception
        Throws:
        Exception
      • createConsumer

        public org.apache.camel.Consumer createConsumer​(org.apache.camel.Processor processor)
                                                 throws Exception
        Throws:
        Exception
      • createPollingConsumer

        public org.apache.camel.PollingConsumer createPollingConsumer()
                                                               throws Exception
        Specified by:
        createPollingConsumer in interface org.apache.camel.Endpoint
        Overrides:
        createPollingConsumer in class org.apache.camel.support.DefaultEndpoint
        Throws:
        Exception
      • getHttpClient

        public org.apache.http.client.HttpClient getHttpClient()
      • setHttpClient

        public void setHttpClient​(org.apache.http.client.HttpClient httpClient)
        Sets a custom HttpClient to be used by the producer
      • createHttpClient

        protected org.apache.http.client.HttpClient createHttpClient()
        Factory method to create a new HttpClient instance

        Producers and consumers should use the getHttpClient() method instead.

      • getComponent

        public HttpComponent getComponent()
        Overrides:
        getComponent in class org.apache.camel.http.common.HttpCommonEndpoint
      • doStop

        protected void doStop()
                       throws Exception
        Overrides:
        doStop in class org.apache.camel.support.DefaultEndpoint
        Throws:
        Exception
      • getClientBuilder

        public org.apache.http.impl.client.HttpClientBuilder getClientBuilder()
      • setClientBuilder

        public void setClientBuilder​(org.apache.http.impl.client.HttpClientBuilder clientBuilder)
        Provide access to the http client request parameters used on new RequestConfig instances used by producers or consumers of this endpoint.
      • setHttpClientConfigurer

        public void setHttpClientConfigurer​(HttpClientConfigurer httpClientConfigurer)
        Register a custom configuration strategy for new HttpClient instances created by producers or consumers such as to configure authentication mechanisms etc
      • getHttpContext

        public org.apache.http.protocol.HttpContext getHttpContext()
      • setHttpContext

        public void setHttpContext​(org.apache.http.protocol.HttpContext httpContext)
        To use a custom HttpContext instance
      • getClientConnectionManager

        public org.apache.http.conn.HttpClientConnectionManager getClientConnectionManager()
      • setClientConnectionManager

        public void setClientConnectionManager​(org.apache.http.conn.HttpClientConnectionManager clientConnectionManager)
        To use a custom HttpClientConnectionManager to manage connections
      • isClearExpiredCookies

        public boolean isClearExpiredCookies()
      • setClearExpiredCookies

        public void setClearExpiredCookies​(boolean clearExpiredCookies)
        Whether to clear expired cookies before sending the HTTP request. This ensures the cookies store does not keep growing by adding new cookies which is newer removed when they are expired.
      • isDeleteWithBody

        public boolean isDeleteWithBody()
      • setDeleteWithBody

        public void setDeleteWithBody​(boolean deleteWithBody)
        Whether the HTTP DELETE should include the message body or not.

        By default HTTP DELETE do not include any HTTP body. However in some rare cases users may need to be able to include the message body.

      • isGetWithBody

        public boolean isGetWithBody()
      • setGetWithBody

        public void setGetWithBody​(boolean getWithBody)
        Whether the HTTP GET should include the message body or not.

        By default HTTP GET do not include any HTTP body. However in some rare cases users may need to be able to include the message body.

      • getCookieStore

        public org.apache.http.client.CookieStore getCookieStore()
      • setCookieStore

        public void setCookieStore​(org.apache.http.client.CookieStore cookieStore)
        To use a custom CookieStore. By default the BasicCookieStore is used which is an in-memory only cookie store. Notice if bridgeEndpoint=true then the cookie store is forced to be a noop cookie store as cookie shouldn't be stored as we are just bridging (eg acting as a proxy). If a cookieHandler is set then the cookie store is also forced to be a noop cookie store as cookie handling is then performed by the cookieHandler.
      • setCookieHandler

        public void setCookieHandler​(org.apache.camel.http.base.cookie.CookieHandler cookieHandler)
        Overrides:
        setCookieHandler in class org.apache.camel.http.common.HttpCommonEndpoint
      • isAuthenticationPreemptive

        public boolean isAuthenticationPreemptive()
      • setAuthenticationPreemptive

        public void setAuthenticationPreemptive​(boolean authenticationPreemptive)
        If this option is true, camel-http sends preemptive basic authentication to the server.
      • getHttpClientOptions

        public Map<String,​Object> getHttpClientOptions()
      • setHttpClientOptions

        public void setHttpClientOptions​(Map<String,​Object> httpClientOptions)
        To configure the HttpClient using the key/values from the Map.
      • isUseSystemProperties

        public boolean isUseSystemProperties()
      • setUseSystemProperties

        public void setUseSystemProperties​(boolean useSystemProperties)
        To use System Properties as fallback for configuration
      • getMaxTotalConnections

        public int getMaxTotalConnections()
      • setMaxTotalConnections

        public void setMaxTotalConnections​(int maxTotalConnections)
        The maximum number of connections.
      • getConnectionsPerRoute

        public int getConnectionsPerRoute()
      • setConnectionsPerRoute

        public void setConnectionsPerRoute​(int connectionsPerRoute)
        The maximum number of connections per route.
      • setX509HostnameVerifier

        public void setX509HostnameVerifier​(HostnameVerifier x509HostnameVerifier)
        To use a custom X509HostnameVerifier such as DefaultHostnameVerifier or NoopHostnameVerifier.
      • getSslContextParameters

        public org.apache.camel.support.jsse.SSLContextParameters getSslContextParameters()
      • setSslContextParameters

        public void setSslContextParameters​(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters)
        To configure security using SSLContextParameters. Important: Only one instance of org.apache.camel.util.jsse.SSLContextParameters is supported per HttpComponent. If you need to use 2 or more different instances, you need to define a new HttpComponent per instance you need.
      • getConnectionRequestTimeout

        public long getConnectionRequestTimeout()
      • setConnectionRequestTimeout

        public void setConnectionRequestTimeout​(long connectionRequestTimeout)
        The timeout in milliseconds used when requesting a connection from the connection manager. A timeout value of zero is interpreted as an infinite timeout.

        A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default).

        Default: -1

      • getConnectTimeout

        public long getConnectTimeout()
      • setConnectTimeout

        public void setConnectTimeout​(long connectTimeout)
        Determines the timeout in milliseconds until a connection is established. A timeout value of zero is interpreted as an infinite timeout.

        A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default).

        Default: -1

      • getSocketTimeout

        public long getSocketTimeout()
      • setSocketTimeout

        public void setSocketTimeout​(long socketTimeout)
        Defines the socket timeout (SO_TIMEOUT) in milliseconds, which is the timeout for waiting for data or, put differently, a maximum period inactivity between two consecutive data packets).

        A timeout value of zero is interpreted as an infinite timeout. A negative value is interpreted as undefined (system default).

        Default: -1

      • setCustomHostHeader

        public void setCustomHostHeader​(String customHostHeader)
        Defines a custom host header which will be sent when producing http request.

        When not set in query will be ignored. When set will override host header derived from url.

        Default: null

      • getCustomHostHeader

        public String getCustomHostHeader()
      • getClientConnectionsPoolStatsMax

        @ManagedAttribute(description="Maximum number of allowed persistent connections")
        public int getClientConnectionsPoolStatsMax()
      • getClientConnectionsPoolStatsAvailable

        @ManagedAttribute(description="Number of available idle persistent connections")
        public int getClientConnectionsPoolStatsAvailable()
      • getClientConnectionsPoolStatsLeased

        @ManagedAttribute(description="Number of persistent connections tracked by the connection manager currently being used to execute requests")
        public int getClientConnectionsPoolStatsLeased()
      • getClientConnectionsPoolStatsPending

        @ManagedAttribute(description="Number of connection requests being blocked awaiting a free connection. This can happen only if there are more worker threads contending for fewer connections.")
        public int getClientConnectionsPoolStatsPending()