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.ComponentAware,org.apache.camel.Endpoint,org.apache.camel.IsSingleton,org.apache.camel.LineNumberAware,org.apache.camel.Service,org.apache.camel.ShutdownableService,org.apache.camel.spi.EndpointServiceLocation,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",
annotations="protocol=http")
@ManagedResource(description="Managed HttpEndpoint")
public class HttpEndpoint
extends org.apache.camel.http.common.HttpCommonEndpoint
implements org.apache.camel.LineNumberAware
Send requests to external HTTP servers using Apache HTTP Client 5.x.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.apache.camel.support.jsse.SSLContextParametersFields 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
ConstructorsConstructorDescriptionHttpEndpoint(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 TypeMethodDescriptionorg.apache.camel.ConsumercreateConsumer(org.apache.camel.Processor processor) protected org.apache.hc.client5.http.classic.HttpClientFactory method to create a newHttpClientinstanceorg.apache.camel.PollingConsumerorg.apache.camel.Producerprotected voiddoStart()protected voiddoStop()org.apache.hc.client5.http.impl.classic.HttpClientBuilderorg.apache.hc.client5.http.io.HttpClientConnectionManagerintintintintlongintlongorg.apache.hc.client5.http.cookie.CookieStoreorg.apache.hc.client5.http.classic.HttpClientorg.apache.hc.core5.http.protocol.HttpContextintintlonglongorg.apache.camel.support.jsse.SSLContextParametersbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanvoidsetAuthenticationPreemptive(boolean authenticationPreemptive) If this option is true, camel-http sends preemptive basic authentication to the server.voidsetClearExpiredCookies(boolean clearExpiredCookies) Whether to clear expired cookies before sending the HTTP request.voidsetClientBuilder(org.apache.hc.client5.http.impl.classic.HttpClientBuilder clientBuilder) Provide access to the http client request parameters used on newRequestConfiginstances used by producers or consumers of this endpoint.voidsetClientConnectionManager(org.apache.hc.client5.http.io.HttpClientConnectionManager clientConnectionManager) To use a custom HttpClientConnectionManager to manage connectionsvoidsetConnectionRequestTimeout(long connectionRequestTimeout) Returns the connection lease request timeout used when requesting a connection from the connection manager.voidsetConnectionsPerRoute(int connectionsPerRoute) The maximum number of connections per route.voidsetConnectTimeout(long connectTimeout) Determines the timeout until a new connection is fully established.voidsetCookieHandler(org.apache.camel.http.base.cookie.CookieHandler cookieHandler) voidsetCookieStore(org.apache.hc.client5.http.cookie.CookieStore cookieStore) To use a custom CookieStore.voidsetCustomHostHeader(String customHostHeader) Defines a custom host header which will be sent when producing http request.voidsetDeleteWithBody(boolean deleteWithBody) Whether the HTTP DELETE should include the message body or not.voidsetFollowRedirects(boolean followRedirects) Whether to the HTTP request should follow redirects.voidsetGetWithBody(boolean getWithBody) Whether the HTTP GET should include the message body or not.voidsetHttpActivityListener(HttpActivityListener httpActivityListener) voidsetHttpClient(org.apache.hc.client5.http.classic.HttpClient httpClient) Sets a custom HttpClient to be used by the producervoidsetHttpClientConfigurer(HttpClientConfigurer httpClientConfigurer) Register a custom configuration strategy for newHttpClientinstances created by producers or consumers such as to configure authentication mechanisms etcvoidsetHttpClientOptions(Map<String, Object> httpClientOptions) To configure the HttpClient using the key/values from the Map.voidsetHttpConnectionOptions(Map<String, Object> httpConnectionOptions) To configure the connection and the socket using the key/values from the Map.voidsetHttpContext(org.apache.hc.core5.http.protocol.HttpContext httpContext) To use a custom HttpContext instancevoidsetLineNumber(int lineNumber) voidsetLocation(String location) voidsetLogHttpActivity(boolean logHttpActivity) voidsetMaxTotalConnections(int maxTotalConnections) The maximum number of connections.voidsetMultipartUpload(boolean multipartUpload) voidsetMultipartUploadName(String multipartUploadName) voidsetResponseTimeout(long responseTimeout) Determines the timeout until arrival of a response from the opposite endpoint.voidsetSkipControlHeaders(boolean skipControlHeaders) Whether to skip Camel control headers (CamelHttp... headers) to influence this endpoint.voidsetSkipRequestHeaders(boolean skipRequestHeaders) Whether to skip mapping the Camel headers as HTTP request headers.voidsetSkipResponseHeaders(boolean skipResponseHeaders) Whether to skip mapping all the HTTP response headers to Camel headers.voidsetSoTimeout(long soTimeout) Determines the default socket timeout value for blocking I/O operations.voidsetSslContextParameters(org.apache.camel.support.jsse.SSLContextParameters sslContextParameters) To configure security using SSLContextParameters.voidsetUserAgent(String userAgent) To set a custom HTTP User-Agent request headervoidsetUseSystemProperties(boolean useSystemProperties) To use System Properties as fallback for configurationvoidsetX509HostnameVerifier(HostnameVerifier x509HostnameVerifier) To use a custom X509HostnameVerifier such asDefaultHostnameVerifierorNoopHostnameVerifier.Methods inherited from class org.apache.camel.http.common.HttpCommonEndpoint
canConnect, connect, disconnect, getAuthBearerToken, getAuthDomain, getAuthHost, getAuthMethod, getAuthPassword, getAuthUsername, getBinding, getCookieHandler, getHeaderFilterStrategy, getHttpBinding, getHttpMethod, getHttpMethodRestrict, getHttpUri, getOauth2CachedTokensDefaultExpirySeconds, getOauth2CachedTokensExpirationMarginSeconds, getOauth2ClientId, getOauth2ClientSecret, getOauth2ResourceIndicator, getOauth2Scope, getOauth2TokenEndpoint, getOkStatusCodeRange, getPath, getPort, getProtocol, getProxyAuthDomain, getProxyAuthHost, getProxyAuthMethod, getProxyAuthNtHost, getProxyAuthPassword, getProxyAuthPort, getProxyAuthScheme, getProxyAuthUsername, getProxyHost, getProxyPort, getResponseBufferSize, getServiceProperties, getServiceProtocol, getServiceUrl, isAsync, isBridgeEndpoint, isChunked, isConnectionClose, isCopyHeaders, isDisableStreamCache, isEagerCheckContentAvailable, isIgnoreResponseBody, isLenientProperties, isLogException, isMapHttpMessageBody, isMapHttpMessageFormUrlEncodedBody, isMapHttpMessageHeaders, isMatchOnUriPrefix, isMuteException, isOauth2CacheTokens, isOptionsEnabled, isPreserveHostHeader, isThrowExceptionOnFailure, isTraceEnabled, isTransferException, setAsync, setAuthBearerToken, setAuthDomain, setAuthHost, setAuthMethod, setAuthPassword, setAuthUsername, setBridgeEndpoint, setChunked, setConnectionClose, setCopyHeaders, setDisableStreamCache, setEagerCheckContentAvailable, setHeaderFilterStrategy, setHttpBinding, setHttpMethod, setHttpMethodRestrict, setHttpUri, setIgnoreResponseBody, setLogException, setMapHttpMessageBody, setMapHttpMessageFormUrlEncodedBody, setMapHttpMessageHeaders, setMatchOnUriPrefix, setMuteException, setOauth2CachedTokensDefaultExpirySeconds, setOauth2CachedTokensExpirationMarginSeconds, setOauth2CacheTokens, setOauth2ClientId, setOauth2ClientSecret, setOauth2ResourceIndicator, setOauth2Scope, setOauth2TokenEndpoint, setOkStatusCodeRange, setOptionsEnabled, setPreserveHostHeader, setProxyAuthDomain, setProxyAuthHost, setProxyAuthMethod, setProxyAuthNtHost, setProxyAuthPassword, setProxyAuthPort, setProxyAuthScheme, setProxyAuthUsername, setProxyHost, setProxyPort, setResponseBufferSize, setThrowExceptionOnFailure, setTraceEnabled, setTransferExceptionMethods 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, toStringMethods inherited from class org.apache.camel.support.service.BaseService
build, doBuild, doFail, doLifecycleChange, doResume, doShutdown, doSuspend, fail, getInternalLock, getStatus, init, isBuild, isInit, isNew, isRunAllowed, isShutdown, isStarted, isStarting, isStartingOrStarted, isStopped, isStopping, isStoppingOrStopped, isSuspended, isSuspending, isSuspendingOrSuspended, resume, shutdown, start, stop, suspendMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.camel.ComponentAware
getComponentMethods inherited from interface org.apache.camel.Endpoint
getEndpointBaseUri, isRemote, isSingletonProducerMethods inherited from interface org.apache.camel.spi.EndpointServiceLocation
getServiceMetadataMethods inherited from interface org.apache.camel.Service
build, close, init, start, stopMethods inherited from interface org.apache.camel.ShutdownableService
shutdownMethods inherited from interface org.apache.camel.StatefulService
getStatus, isRunAllowed, isStarted, isStarting, isStopped, isStopping, isSuspendingMethods 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
-
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
- Specified by:
createProducerin interfaceorg.apache.camel.Endpoint- Throws:
Exception
-
createConsumer
public org.apache.camel.Consumer createConsumer(org.apache.camel.Processor processor) throws Exception - Specified by:
createConsumerin interfaceorg.apache.camel.Endpoint- Throws:
Exception
-
createPollingConsumer
- Specified by:
createPollingConsumerin interfaceorg.apache.camel.Endpoint- Overrides:
createPollingConsumerin classorg.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 newHttpClientinstance Producers and consumers should use thegetHttpClient()method instead. -
getComponent
- Specified by:
getComponentin interfaceorg.apache.camel.ComponentAware- Overrides:
getComponentin classorg.apache.camel.http.common.HttpCommonEndpoint
-
doStart
- Overrides:
doStartin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
doStop
- Overrides:
doStopin classorg.apache.camel.support.service.BaseService- Throws:
Exception
-
getLineNumber
public int getLineNumber()- Specified by:
getLineNumberin interfaceorg.apache.camel.LineNumberAware
-
setLineNumber
public void setLineNumber(int lineNumber) - Specified by:
setLineNumberin interfaceorg.apache.camel.LineNumberAware
-
getLocation
- Specified by:
getLocationin interfaceorg.apache.camel.LineNumberAware
-
setLocation
- Specified by:
setLocationin interfaceorg.apache.camel.LineNumberAware
-
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 newRequestConfiginstances used by producers or consumers of this endpoint. -
getHttpClientConfigurer
-
setHttpClientConfigurer
Register a custom configuration strategy for newHttpClientinstances 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:
setCookieHandlerin 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. -
getHttpClientOptions
-
setHttpClientOptions
To configure the HttpClient using the key/values from the Map. -
getHttpConnectionOptions
-
setHttpConnectionOptions
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
-
setX509HostnameVerifier
To use a custom X509HostnameVerifier such asDefaultHostnameVerifierorNoopHostnameVerifier. -
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) 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 long getConnectTimeout() -
setConnectTimeout
public void setConnectTimeout(long connectTimeout) Determines the timeout until a new connection is fully established. This may also include transport security negotiation exchanges such asSSLorTLSprotocol negotiation).A timeout value of zero is interpreted as an infinite timeout.
Default: 3 minutes
-
getSoTimeout
public long getSoTimeout() -
setSoTimeout
public void setSoTimeout(long soTimeout) Determines the default socket timeout value for blocking I/O operations.Default: 3 minutes
-
getResponseTimeout
public long getResponseTimeout() -
setResponseTimeout
public void setResponseTimeout(long 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
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
-
isSkipRequestHeaders
public boolean isSkipRequestHeaders() -
setSkipRequestHeaders
public void setSkipRequestHeaders(boolean skipRequestHeaders) Whether to skip mapping the Camel headers as HTTP request headers. This is useful when you know that calling the HTTP service should not include any custom headers. -
isSkipControlHeaders
public boolean isSkipControlHeaders() -
setSkipControlHeaders
public void setSkipControlHeaders(boolean skipControlHeaders) Whether to skip Camel control headers (CamelHttp... headers) to influence this endpoint. Control headers from previous HTTP components can influence how this Camel component behaves such as CamelHttpPath, CamelHttpQuery, etc. -
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. -
getUserAgent
-
setUserAgent
To set a custom HTTP User-Agent request header -
getHttpActivityListener
-
setHttpActivityListener
-
isLogHttpActivity
public boolean isLogHttpActivity() -
setLogHttpActivity
public void setLogHttpActivity(boolean logHttpActivity) -
isMultipartUpload
public boolean isMultipartUpload() -
setMultipartUpload
public void setMultipartUpload(boolean multipartUpload) -
getMultipartUploadName
-
setMultipartUploadName
-
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()
-