Class HttpEndpoint

java.lang.Object
org.apache.camel.support.service.BaseService
org.apache.camel.support.service.ServiceSupport
org.apache.camel.support.DefaultEndpoint
org.apache.camel.http.common.HttpCommonEndpoint
org.apache.camel.component.http.HttpEndpoint
All Implemented Interfaces:
AutoCloseable, org.apache.camel.CamelContextAware, org.apache.camel.cloud.DiscoverableService, org.apache.camel.ComponentAware, org.apache.camel.Endpoint, org.apache.camel.IsSingleton, org.apache.camel.Service, org.apache.camel.ShutdownableService, org.apache.camel.spi.HasCamelContext, 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, headersClass=HttpConstants.class) @Metadata(excludeProperties="httpBinding,matchOnUriPrefix,chunked,transferException") @ManagedResource(description="Managed HttpEndpoint") public class HttpEndpoint extends org.apache.camel.http.common.HttpCommonEndpoint
Send requests to external HTTP servers using Apache HTTP Client 5.x.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected org.apache.camel.support.jsse.SSLContextParameters
     

    Fields inherited from class org.apache.camel.support.service.BaseService

    BUILT, FAILED, INITIALIZED, INITIALIZING, lock, NEW, SHUTDOWN, SHUTTING_DOWN, STARTED, STARTING, status, STOPPED, STOPPING, SUSPENDED, SUSPENDING
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI)
     
    HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI, org.apache.hc.client5.http.impl.classic.HttpClientBuilder clientBuilder, org.apache.hc.client5.http.io.HttpClientConnectionManager clientConnectionManager, HttpClientConfigurer clientConfigurer)
     
    HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI, org.apache.hc.client5.http.io.HttpClientConnectionManager clientConnectionManager)
     
    HttpEndpoint(String endPointURI, HttpComponent component, org.apache.hc.client5.http.impl.classic.HttpClientBuilder clientBuilder, org.apache.hc.client5.http.io.HttpClientConnectionManager clientConnectionManager, HttpClientConfigurer clientConfigurer)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    org.apache.camel.Consumer
    createConsumer(org.apache.camel.Processor processor)
     
    protected org.apache.hc.client5.http.classic.HttpClient
    Factory method to create a new HttpClient instance
    org.apache.camel.PollingConsumer
     
    org.apache.camel.Producer
     
    protected void
     
    org.apache.hc.client5.http.impl.classic.HttpClientBuilder
     
    org.apache.hc.client5.http.io.HttpClientConnectionManager
     
    int
     
    int
     
    int
     
    int
     
     
    org.apache.hc.core5.util.Timeout
     
    int
     
    org.apache.hc.core5.util.Timeout
     
    org.apache.hc.client5.http.cookie.CookieStore
     
     
    org.apache.hc.client5.http.classic.HttpClient
     
     
     
     
    org.apache.hc.core5.http.protocol.HttpContext
     
    int
     
    org.apache.hc.core5.util.Timeout
     
    org.apache.hc.core5.util.Timeout
     
    org.apache.camel.support.jsse.SSLContextParameters
     
     
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    boolean
     
    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.hc.client5.http.impl.classic.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.hc.client5.http.io.HttpClientConnectionManager clientConnectionManager)
    To use a custom HttpClientConnectionManager to manage connections
    void
    setConnectionRequestTimeout(org.apache.hc.core5.util.Timeout connectionRequestTimeout)
    Returns the connection lease request timeout used when requesting a connection from the connection manager.
    void
    setConnectionsPerRoute(int connectionsPerRoute)
    The maximum number of connections per route.
    void
    setConnectTimeout(org.apache.hc.core5.util.Timeout connectTimeout)
    Determines the timeout until a new connection is fully established.
    void
    setCookieHandler(org.apache.camel.http.base.cookie.CookieHandler cookieHandler)
     
    void
    setCookieStore(org.apache.hc.client5.http.cookie.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
    setFollowRedirects(boolean followRedirects)
    Whether to the HTTP request should follow redirects.
    void
    setGetWithBody(boolean getWithBody)
    Whether the HTTP GET should include the message body or not.
    void
    setHttpClient(org.apache.hc.client5.http.classic.HttpClient httpClient)
    Sets a custom HttpClient to be used by the producer
    void
    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
    setHttpConnectionOptions(Map<String,Object> httpConnectionOptions)
    To configure the connection and the socket using the key/values from the Map.
    void
    setHttpContext(org.apache.hc.core5.http.protocol.HttpContext httpContext)
    To use a custom HttpContext instance
    void
    setMaxTotalConnections(int maxTotalConnections)
    The maximum number of connections.
    void
    setResponseTimeout(org.apache.hc.core5.util.Timeout responseTimeout)
    Determines the timeout until arrival of a response from the opposite endpoint.
    void
    setSkipRequestHeaders(boolean skipRequestHeaders)
    Whether to skip mapping all the Camel headers as HTTP request headers.
    void
    setSkipResponseHeaders(boolean skipResponseHeaders)
    Whether to skip mapping all the HTTP response headers to Camel headers.
    void
    setSoTimeout(org.apache.hc.core5.util.Timeout soTimeout)
    Determines the default socket timeout value for blocking I/O operations.
    void
    setSslContextParameters(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters)
    To configure security using SSLContextParameters.
    void
    setUserAgent(String userAgent)
    To set a custom HTTP User-Agent request header
    void
    setUseSystemProperties(boolean useSystemProperties)
    To use System Properties as fallback for configuration
    void
    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, getOauth2ClientId, getOauth2ClientSecret, getOauth2TokenEndpoint, getOkStatusCodeRange, getPath, getPort, getProtocol, getProxyAuthDomain, getProxyAuthHost, getProxyAuthMethod, getProxyAuthNtHost, getProxyAuthPassword, getProxyAuthPort, getProxyAuthScheme, getProxyAuthUsername, getProxyHost, getProxyPort, getResponseBufferSize, getServiceProperties, isAsync, isBridgeEndpoint, isChunked, isConnectionClose, isCopyHeaders, isDisableStreamCache, isEagerCheckContentAvailable, isIgnoreResponseBody, isLenientProperties, isLogException, isMapHttpMessageBody, isMapHttpMessageFormUrlEncodedBody, isMapHttpMessageHeaders, isMatchOnUriPrefix, isMuteException, isOptionsEnabled, isPreserveHostHeader, isThrowExceptionOnFailure, isTraceEnabled, isTransferException, setAsync, setAuthDomain, setAuthHost, setAuthMethod, setAuthMethodPriority, setAuthPassword, setAuthUsername, setBridgeEndpoint, setChunked, setConnectionClose, setCopyHeaders, setDisableStreamCache, setEagerCheckContentAvailable, setHeaderFilterStrategy, setHttpBinding, setHttpMethod, setHttpMethodRestrict, setHttpUri, setIgnoreResponseBody, setLogException, setMapHttpMessageBody, setMapHttpMessageFormUrlEncodedBody, setMapHttpMessageHeaders, setMatchOnUriPrefix, setMuteException, setOauth2ClientId, setOauth2ClientSecret, setOauth2TokenEndpoint, setOkStatusCodeRange, setOptionsEnabled, setPreserveHostHeader, setProxyAuthDomain, setProxyAuthHost, setProxyAuthMethod, setProxyAuthNtHost, setProxyAuthPassword, setProxyAuthPort, setProxyAuthScheme, setProxyAuthUsername, setProxyHost, setProxyPort, setResponseBufferSize, setThrowExceptionOnFailure, setTraceEnabled, setTransferException

    Methods inherited from class org.apache.camel.support.DefaultEndpoint

    configureConsumer, configureExchange, configurePollingConsumer, configureProperties, createAsyncProducer, createEndpointUri, createExchange, createExchange, doInit, equals, getCamelContext, getEndpointKey, getEndpointUri, getExceptionHandler, getExchangePattern, getId, getPollingConsumerBlockTimeout, getPollingConsumerQueueSize, hashCode, isAutowiredEnabled, isBridgeErrorHandler, isLazyStartProducer, isPollingConsumerBlockWhenFull, isPollingConsumerCopy, isSingleton, setAutowiredEnabled, setBridgeErrorHandler, setCamelContext, setComponent, setEndpointUri, setEndpointUriIfNotSpecified, setExceptionHandler, setExchangePattern, setLazyStartProducer, setPollingConsumerBlockTimeout, setPollingConsumerBlockWhenFull, setPollingConsumerCopy, setPollingConsumerQueueSize, setProperties, toString

    Methods inherited from class org.apache.camel.support.service.BaseService

    build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doStart, 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 class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.camel.ComponentAware

    getComponent

    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 Details

    • 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
  • Constructor Details

    • HttpEndpoint

      public HttpEndpoint()
    • HttpEndpoint

      public HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI)
    • HttpEndpoint

      public HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI, org.apache.hc.client5.http.io.HttpClientConnectionManager clientConnectionManager)
    • HttpEndpoint

      public HttpEndpoint(String endPointURI, HttpComponent component, org.apache.hc.client5.http.impl.classic.HttpClientBuilder clientBuilder, org.apache.hc.client5.http.io.HttpClientConnectionManager clientConnectionManager, HttpClientConfigurer clientConfigurer)
    • HttpEndpoint

      public HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI, org.apache.hc.client5.http.impl.classic.HttpClientBuilder clientBuilder, org.apache.hc.client5.http.io.HttpClientConnectionManager clientConnectionManager, HttpClientConfigurer clientConfigurer)
  • Method Details

    • 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.hc.client5.http.classic.HttpClient getHttpClient()
    • setHttpClient

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

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

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

    • getComponent

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

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

      public org.apache.hc.client5.http.impl.classic.HttpClientBuilder getClientBuilder()
    • setClientBuilder

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

      public HttpClientConfigurer getHttpClientConfigurer()
    • 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.hc.core5.http.protocol.HttpContext getHttpContext()
    • setHttpContext

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

      public org.apache.hc.client5.http.io.HttpClientConnectionManager getClientConnectionManager()
    • setClientConnectionManager

      public void setClientConnectionManager(org.apache.hc.client5.http.io.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. If the component has disabled cookie management then this option is disabled too.
    • 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.hc.client5.http.cookie.CookieStore getCookieStore()
    • setCookieStore

      public void setCookieStore(org.apache.hc.client5.http.cookie.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.
    • getHttpConnectionOptions

      public Map<String,Object> getHttpConnectionOptions()
    • setHttpConnectionOptions

      public void setHttpConnectionOptions(Map<String,Object> httpConnectionOptions)
      To configure the connection and the socket 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.
    • getX509HostnameVerifier

      public HostnameVerifier getX509HostnameVerifier()
    • 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 org.apache.hc.core5.util.Timeout getConnectionRequestTimeout()
    • setConnectionRequestTimeout

      public void setConnectionRequestTimeout(org.apache.hc.core5.util.Timeout connectionRequestTimeout)
      Returns the connection lease request timeout used when requesting a connection from the connection manager.

      A timeout value of zero is interpreted as a disabled timeout.

      Default: 3 minutes

    • getConnectTimeout

      public org.apache.hc.core5.util.Timeout getConnectTimeout()
    • setConnectTimeout

      public void setConnectTimeout(org.apache.hc.core5.util.Timeout connectTimeout)
      Determines the timeout until a new connection is fully established. This may also include transport security negotiation exchanges such as SSL or TLS protocol negotiation).

      A timeout value of zero is interpreted as an infinite timeout.

      Default: 3 minutes

    • getSoTimeout

      public org.apache.hc.core5.util.Timeout getSoTimeout()
    • setSoTimeout

      public void setSoTimeout(org.apache.hc.core5.util.Timeout soTimeout)
      Determines the default socket timeout value for blocking I/O operations.

      Default: 3 minutes

    • getResponseTimeout

      public org.apache.hc.core5.util.Timeout getResponseTimeout()
    • setResponseTimeout

      public void setResponseTimeout(org.apache.hc.core5.util.Timeout responseTimeout)
      Determines the timeout until arrival of a response from the opposite endpoint.

      A timeout value of zero is interpreted as an infinite timeout.

      Please note that response timeout may be unsupported by HTTP transports with message multiplexing.

      Default: 0

    • 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()
    • isSkipRequestHeaders

      public boolean isSkipRequestHeaders()
    • setSkipRequestHeaders

      public void setSkipRequestHeaders(boolean skipRequestHeaders)
      Whether to skip mapping all the Camel headers as HTTP request headers. If there are no data from Camel headers needed to be included in the HTTP request then this can avoid parsing overhead with many object allocations for the JVM garbage collector.
    • isFollowRedirects

      public boolean isFollowRedirects()
    • setFollowRedirects

      public void setFollowRedirects(boolean followRedirects)
      Whether to the HTTP request should follow redirects. By default the HTTP request does not follow redirects
    • isSkipResponseHeaders

      public boolean isSkipResponseHeaders()
    • setSkipResponseHeaders

      public void setSkipResponseHeaders(boolean skipResponseHeaders)
      Whether to skip mapping all the HTTP response headers to Camel headers. If there are no data needed from HTTP headers then this can avoid parsing overhead with many object allocations for the JVM garbage collector.
    • getUserAgent

      public String getUserAgent()
    • setUserAgent

      public void setUserAgent(String userAgent)
      To set a custom HTTP User-Agent request header
    • 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()