Package org.apache.camel.component.http
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.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, 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 4.x.
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.camel.support.jsse.SSLContextParameters
sslContextParameters
-
Constructor Summary
Constructors Constructor Description HttpEndpoint()
HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI)
HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI, org.apache.http.conn.HttpClientConnectionManager clientConnectionManager)
HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI, org.apache.http.impl.client.HttpClientBuilder clientBuilder, org.apache.http.conn.HttpClientConnectionManager clientConnectionManager, HttpClientConfigurer clientConfigurer)
HttpEndpoint(String endPointURI, HttpComponent component, org.apache.http.impl.client.HttpClientBuilder clientBuilder, org.apache.http.conn.HttpClientConnectionManager clientConnectionManager, HttpClientConfigurer clientConfigurer)
-
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 newHttpClient
instanceorg.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()
String
getUserAgent()
HostnameVerifier
getX509HostnameVerifier()
boolean
isAuthenticationPreemptive()
boolean
isClearExpiredCookies()
boolean
isDeleteWithBody()
boolean
isFollowRedirects()
boolean
isGetWithBody()
boolean
isSkipRequestHeaders()
boolean
isSkipResponseHeaders()
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 newRequestConfig
instances used by producers or consumers of this endpoint.void
setClientConnectionManager(org.apache.http.conn.HttpClientConnectionManager clientConnectionManager)
To use a custom HttpClientConnectionManager to manage connectionsvoid
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
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.http.client.HttpClient httpClient)
Sets a custom HttpClient to be used by the producervoid
setHttpClientConfigurer(HttpClientConfigurer httpClientConfigurer)
Register a custom configuration strategy for newHttpClient
instances created by producers or consumers such as to configure authentication mechanisms etcvoid
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 instancevoid
setMaxTotalConnections(int maxTotalConnections)
The maximum number of connections.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
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
setUserAgent(String userAgent)
To set a custom HTTP User-Agent request headervoid
setUseSystemProperties(boolean useSystemProperties)
To use System Properties as fallback for configurationvoid
setX509HostnameVerifier(HostnameVerifier x509HostnameVerifier)
To use a custom X509HostnameVerifier such asDefaultHostnameVerifier
orNoopHostnameVerifier
.-
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, getProxyAuthNtHost, 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, setBridgeEndpoint, setChunked, setConnectionClose, setCopyHeaders, setDisableStreamCache, setEagerCheckContentAvailable, setHeaderFilterStrategy, setHttpBinding, setHttpMethod, setHttpMethodRestrict, setHttpUri, setIgnoreResponseBody, setMapHttpMessageBody, setMapHttpMessageFormUrlEncodedBody, setMapHttpMessageHeaders, setMatchOnUriPrefix, setMuteException, 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, doStart, 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, 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
-
-
-
-
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
-
-
Constructor Detail
-
HttpEndpoint
public HttpEndpoint()
-
HttpEndpoint
public HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI) throws URISyntaxException
- Throws:
URISyntaxException
-
HttpEndpoint
public HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI, org.apache.http.conn.HttpClientConnectionManager clientConnectionManager) throws URISyntaxException
- Throws:
URISyntaxException
-
HttpEndpoint
public HttpEndpoint(String endPointURI, HttpComponent component, org.apache.http.impl.client.HttpClientBuilder clientBuilder, org.apache.http.conn.HttpClientConnectionManager clientConnectionManager, HttpClientConfigurer clientConfigurer) throws URISyntaxException
- Throws:
URISyntaxException
-
HttpEndpoint
public HttpEndpoint(String endPointURI, HttpComponent component, URI httpURI, org.apache.http.impl.client.HttpClientBuilder clientBuilder, org.apache.http.conn.HttpClientConnectionManager clientConnectionManager, HttpClientConfigurer clientConfigurer)
-
-
Method Detail
-
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 interfaceorg.apache.camel.Endpoint
- Overrides:
createPollingConsumer
in classorg.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 newHttpClient
instance Producers and consumers should use thegetHttpClient()
method instead.
-
getComponent
public HttpComponent getComponent()
- Overrides:
getComponent
in classorg.apache.camel.http.common.HttpCommonEndpoint
-
doStop
protected void doStop() throws Exception
- Overrides:
doStop
in classorg.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 newRequestConfig
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 newHttpClient
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. 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.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 classorg.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.
-
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.
-
getX509HostnameVerifier
public HostnameVerifier getX509HostnameVerifier()
-
setX509HostnameVerifier
public void setX509HostnameVerifier(HostnameVerifier x509HostnameVerifier)
To use a custom X509HostnameVerifier such asDefaultHostnameVerifier
orNoopHostnameVerifier
.
-
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()
-
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()
-
-