Camel Spring Boot

HTTP

Send requests to external HTTP servers using Apache HTTP Client 5.x.

What’s inside

Please refer to the above links for usage and configuration details.

Maven coordinates

<dependency>
    <groupId>org.apache.camel.springboot</groupId>
    <artifactId>camel-http-starter</artifactId>
</dependency>

Spring Boot Auto-Configuration

The starter supports 56 options, which are listed below.

Name Description Default Type

camel.component.http.allow-java-serialized-object

Whether to allow Java serialization of a message body with Content-Type application/x-java-serialized-object: a consumer deserializes such a request body and can write a Java object as such a response, and the HTTP producer deserializes such a response body. When not allowed, such a body that is received is dropped (null). This is turned off by default: if you enable it, be aware that Java deserializes the data that the other side sends, which can be a security risk.

false

Boolean

camel.component.http.auth-caching-disabled

Whether to disable the authentication cache of HttpClient. After a successful authentication, the cache lets the next requests to the same host send the credentials without waiting for a 401 challenge. The cache is kept in the HTTP context of the request, which camel-http creates for each message, so it lasts for one message (its retries and redirects), unless the httpContext option holds an AuthCache.

false

Boolean

camel.component.http.automatic-retries-disabled

Whether to disable the automatic retries of HttpClient. By default HttpClient retries a request once: after some I/O errors (such as NoHttpResponseException, but not a timeout) when the method is idempotent, and after a 429 (Too Many Requests) or 503 (Service Unavailable) response, waiting as long as its Retry-After header asks (1 second without it). A long Retry-After can make the request appear to hang.

false

Boolean

camel.component.http.autowired-enabled

Whether autowiring is enabled. This is used for automatic autowiring options (the option must be marked as autowired) by looking up in the registry to find if there is a single instance of matching type, which then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc.

true

Boolean

camel.component.http.client-connection-manager

A shared HttpClientConnectionManager for all the endpoints of this component, instead of a connection pool per endpoint. The options for the connection pool, the TLS and the sockets (such as maxTotalConnections, connectionsPerRoute, connectionTimeToLive, sslContextParameters, x509HostnameVerifier and soTimeout) are then not applied: configure them on this connection manager. The component closes it when it stops. The option is a org.apache.hc.client5.http.io.HttpClientConnectionManager type.

HttpClientConnectionManager

camel.component.http.connect-timeout

The time (in millis) to wait until a new connection to the server, or to the proxy, is established, including its TLS handshake. Zero means no timeout. It can be set on the endpoint too.

180000

Long

camel.component.http.connection-idle-timeout

The maximum time (in millis) a pooled connection can stay idle and still be reused. A connection idle for longer is closed when it would be reused, and the request opens a new one, whatever Keep-Alive timeout the server announced. Set it below the idle timeout of a NAT, firewall or load balancer that drops idle connections silently: the next request on such a connection would otherwise wait for the read timeout and fail. Zero (the default) or a negative value means no limit.

Long

camel.component.http.connection-request-timeout

The time (in millis) to wait for a free connection of the connection pool, when maxTotalConnections or connectionsPerRoute connections are in use; the request then fails with ConnectionRequestTimeoutException. Zero does not wait: the request fails at once when no connection is free. It can be set on the endpoint too.

180000

Long

camel.component.http.connection-state-disabled

Whether to disable the connection state tracking of HttpClient. By default a pooled connection that carries a user identity (the principal of an NTLM authentication or of a TLS client certificate) is reused only by a request with the same identity. camel-http starts each message with a new HTTP context, which has no identity, so such connections are not reused unless this option is enabled.

false

Boolean

camel.component.http.connection-time-to-live

The maximum lifetime (in millis) of a pooled connection, counted from when it was opened, whether busy or idle: an older connection is closed instead of being reused. A negative value (the default) means no limit, and zero means that a connection is never reused.

Long

camel.component.http.connections-per-route

The maximum number of connections to the same route (the scheme, host and port of the target, and the proxy) in the connection pool of an endpoint.

20

Integer

camel.component.http.content-compression-disabled

Whether to disable the content compression of HttpClient: it then sends no Accept-Encoding header and does not decompress the response body. The producer still decompresses a gzip body, unless bridgeEndpoint is enabled.

false

Boolean

camel.component.http.content-type-charset-enabled

Whether to add the charset of the CamelCharsetName header or exchange property to the Content-Type of a String message body, when the Content-Type has no charset. The body is encoded with the charset of the Content-Type, or UTF-8. When false, CamelCharsetName is not used.

true

Boolean

camel.component.http.cookie-management-disabled

Whether to disable the cookie management of HttpClient: it then neither keeps the cookies of the responses nor sends the cookies of the cookie store, and clearExpiredCookies does nothing. A Cookie message header is still sent.

false

Boolean

camel.component.http.cookie-store

A custom CookieStore for the endpoints that have no cookieStore of their own, instead of a BasicCookieStore (in memory) per endpoint. An endpoint with bridgeEndpoint or a cookieHandler keeps no cookies and does not use it. The option is a org.apache.hc.client5.http.cookie.CookieStore type.

CookieStore

camel.component.http.copy-headers

Whether to copy the headers of the request message to the response message, except the HTTP protocol headers such as Content-Type and Content-Length; a header of the HTTP response with the same name wins. When false, the response message has only the headers of the HTTP response.

true

Boolean

camel.component.http.default-user-agent-disabled

Whether HttpClient sends no default User-Agent header (Apache-HttpClient and its version) when the userAgent option is not set.

false

Boolean

camel.component.http.deserialization-filter

Sets an ObjectInputFilter pattern (jdk.serialFilter syntax) applied when deserializing Java objects from requests or responses with Content-Type application/x-java-serialized-object (only used when allowJavaSerializedObject or transferException is enabled). When not set, the JVM-wide jdk.serialFilter is used if present; otherwise a default filter is applied that rejects java.net., allows java., javax.* and org.apache.camel.*, and rejects every other class.

String

camel.component.http.enabled

Whether to enable auto configuration of the http component. This is enabled by default.

Boolean

camel.component.http.follow-redirects

Whether HttpClient follows redirect responses (3xx with a Location header) to the new location. By default a redirect is not followed: the redirect response is the result, which fails with HttpOperationFailedException (with the redirect location) when throwExceptionOnFailure is enabled.

false

Boolean

camel.component.http.header-filter-strategy

To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter header to and from Camel message. The option is a org.apache.camel.spi.HeaderFilterStrategy type.

HeaderFilterStrategy

camel.component.http.hostname-verification-policy

How the host name in the certificate of the server is verified. CLIENT (the default) uses only x509HostnameVerifier, after the TLS handshake, so a NoopHostnameVerifier turns the check off. BUILTIN uses only the check of the JSSE provider (the JDK), during the handshake, and ignores x509HostnameVerifier. BOTH runs the JSSE check and then x509HostnameVerifier, so a NoopHostnameVerifier cannot turn the check off. BOTH is the safer choice when no custom verifier is needed.

client

HostnameVerificationPolicy

camel.component.http.http-activity-listener

A custom HttpActivityListener for the endpoints that have no httpActivityListener of their own. It is called when a request is sent and when its response is received, for example to log the HTTP traffic. The option is a org.apache.camel.component.http.HttpActivityListener type.

HttpActivityListener

camel.component.http.http-binding

To use a custom HttpBinding for the consumers of this component, which reads the HTTP servlet request into the Camel message and writes the Camel message to the HTTP servlet response. The HTTP producer (camel-http) does not use it. The option is a org.apache.camel.http.common.HttpBinding type.

HttpBinding

camel.component.http.http-client-configurer

The HttpClientConfigurer for the endpoints that have no httpClientConfigurer of their own. It is called with the HttpClientBuilder of the endpoint before the HttpClient is built, for example to configure authentication. The option is a org.apache.camel.component.http.HttpClientConfigurer type.

HttpClientConfigurer

camel.component.http.http-configuration

A shared HttpConfiguration with default options for the endpoints that this component creates; an option set on the endpoint takes precedence. Only the HTTP producer (camel-http) uses it, and only its authentication options (authMethod, which must be set, with the credentials) configure the HTTP client. The consumer components ignore it. The option is a org.apache.camel.http.common.HttpConfiguration type.

HttpConfiguration

camel.component.http.http-context

A custom HttpContext for the endpoints that have no httpContext of their own. Each request runs in a new context that has this one as parent: HttpClient reads attributes from it (such as an AuthCache, a CookieStore or a user token), but the attributes set during a request are not kept in it. The option is a org.apache.hc.core5.http.protocol.HttpContext type.

HttpContext

camel.component.http.lazy-start-producer

Whether the producer should be started lazy (on the first message). By starting lazy you can use this to allow CamelContext and routes to startup in situations where a producer may otherwise fail during starting and cause the route to fail being started. By deferring this startup to be lazy then the startup failure can be handled during routing messages via Camel’s routing error handlers. Beware that when the first message is processed then creating and starting the producer may take a little time and prolong the total processing time of the processing.

false

Boolean

camel.component.http.log-http-activity

Whether to log each HTTP request and response with a LoggingHttpActivityListener, when no httpActivityListener is set. To choose what is logged, set a LoggingHttpActivityListener of your own as httpActivityListener.

false

Boolean

camel.component.http.max-total-connections

The maximum number of connections in the connection pool of an endpoint (each endpoint has its own pool, unless clientConnectionManager is set). A request that finds no free connection waits up to connectionRequestTimeout.

200

Integer

camel.component.http.non-proxy-hosts

Comma-separated list of hosts that should bypass the proxy. Supports wildcards, e.g., localhost,.example.com,192.168..

String

camel.component.http.proxy-auth-domain

The domain for NTLM authentication with the proxy server (NTLM is deprecated). When set, the proxy credentials are NTLM credentials (NTCredentials).

String

camel.component.http.proxy-auth-method

The authentication method for the proxy server: Basic, Digest or NTLM (NTLM is deprecated). camel-http does not use this option: HttpClient uses the method that the proxy asks for in its 407 response, with NTLM credentials (NTCredentials) when proxyAuthDomain is set.

String

camel.component.http.proxy-auth-nt-host

The workstation name for NTLM authentication with the proxy server, used together with proxyAuthDomain (NTLM is deprecated).

String

camel.component.http.proxy-auth-password

The password for authentication with the proxy server, used together with proxyAuthUsername.

String

camel.component.http.proxy-auth-scheme

Proxy server connection protocol scheme. Defaults to http regardless of the target endpoint scheme, because most corporate HTTP proxies expect a plain HTTP connection on their listener port.

http

String

camel.component.http.proxy-auth-username

The username for authentication with the proxy server, used together with proxyAuthPassword.

String

camel.component.http.proxy-host

The host name of the HTTP proxy server. A proxy is used only when both proxyHost and proxyPort are set.

String

camel.component.http.proxy-port

The port of the HTTP proxy server.

Integer

camel.component.http.redirect-handling-disabled

Whether to disable the redirect handling of HttpClient, so that redirects are never followed, even with followRedirects enabled. Without followRedirects, redirects are not followed anyway.

false

Boolean

camel.component.http.response-payload-streaming-threshold

The maximum size in bytes, by its Content-Length, of a response body that is read into a byte array. A larger body, or one without Content-Length, is read into a stream cache. Zero or a negative value always uses the stream cache. With disableStreamCache, the body is always the response stream.

8192

Integer

camel.component.http.response-timeout

The socket timeout (in millis) while a request runs, instead of soTimeout: the maximum time to wait for data on a read. Zero (the default) means not set, so soTimeout applies. It can be set on the endpoint too.

Long

camel.component.http.skip-control-headers

Whether to ignore the Camel control headers of the message: CamelHttpUri, CamelHttpPath, CamelHttpQuery, CamelHttpRawQuery, CamelRestHttpUri, CamelRestHttpQuery, CamelHttpMethod and CamelHttpProtocolVersion. Such headers, left by a previous HTTP component, would otherwise change the URI or the method of the request.

false

Boolean

camel.component.http.skip-request-headers

Whether to send none of the message headers as HTTP request headers, for an HTTP service that must not receive custom headers. The Content-Type header is still used for the request body.

false

Boolean

camel.component.http.skip-response-headers

Whether to not map the HTTP response headers to message headers. The CamelHttpResponseCode and CamelHttpResponseText headers are still set.

false

Boolean

camel.component.http.so-timeout

The socket timeout (SO_TIMEOUT, in millis) of the connections: the maximum time to wait for data on a read, while waiting for the response and while reading it. Zero means no timeout. When responseTimeout is set, it replaces this timeout while a request runs. It can be set on the endpoint too.

180000

Long

camel.component.http.ssl-bundle

The name of the Spring Boot SSL bundle to use for configuring SSL on the HTTP component. When set, the SSL bundle’s trust material and key material will be used to create the SSLContext for HTTPS connections.

String

camel.component.http.ssl-bundle-hot-reload

Whether to enable hot-reload of SSL certificates when the SSL bundle is updated. When enabled, certificate changes trigger recreation of the connection manager so new connections use the updated certificates. Requires the SSL bundle to have reload-on-update enabled in Spring Boot configuration.

false

Boolean

camel.component.http.ssl-context-parameters

The SSLContextParameters (key store, trust store, protocols and cipher suites) for the TLS connections of the endpoints that have no sslContextParameters of their own. An endpoint that has SSLContextParameters uses https, also when its URI starts with http. The option is a org.apache.camel.support.jsse.SSLContextParameters type.

SSLContextParameters

camel.component.http.use-global-ssl-context-parameters

Whether the https endpoints that have no sslContextParameters (and whose component has none) use the global SSLContextParameters of the CamelContext.

false

Boolean

camel.component.http.use-system-properties

Whether HttpClient takes its defaults from the JVM system properties: the proxy (http.proxyHost, https.proxyHost and http.nonProxyHosts, through the default ProxySelector), the User-Agent (http.agent), connection reuse (http.keepAlive), the credentials of the default java.net.Authenticator and, without sslContextParameters, the key store and trust store of the TLS connections (javax.net.ssl.*).

false

Boolean

camel.component.http.user-agent

The User-Agent header that HttpClient adds to the requests that do not have one already, for example from a User-Agent message header.

String

camel.component.http.validate-after-inactivity

The time (in millis) a pooled connection must have been idle before it is checked, prior to its reuse, for having been closed by the server. A request sent on a connection that the server closed fails with NoHttpResponseException, and HttpClient retries it only for idempotent methods. Zero checks the connection before each reuse, at the cost of a read of up to 1 millisecond per request; a negative value disables the check. The check cannot see a connection that a NAT or firewall dropped silently: use connectionIdleTimeout for that.

2000

Long

camel.component.http.x509-hostname-verifier

The HostnameVerifier that checks the host name in the certificate of the server, after the TLS handshake: DefaultHostnameVerifier (the default) or a custom one. NoopHostnameVerifier turns the check off, which is insecure. Not used with hostnameVerificationPolicy BUILTIN. The option is a javax.net.ssl.HostnameVerifier type.

HostnameVerifier

camel.component.http.proxy-auth-host

Deprecated: use proxyHost. The host name of the HTTP proxy server; when set, it takes precedence over proxyHost.

String

camel.component.http.proxy-auth-port

Deprecated: use proxyPort. The port of the HTTP proxy server; when set, it takes precedence over proxyPort.

Integer