Netty HTTP
Expose HTTP endpoints and send requests to HTTP servers, using Netty.
What’s inside
-
Netty HTTP component, URI syntax:
netty-http:protocol://host:port/path
Please refer to the above links for usage and configuration details.
Maven coordinates
<dependency>
<groupId>org.apache.camel.springboot</groupId>
<artifactId>camel-netty-http-starter</artifactId>
</dependency> Spring Boot Auto-Configuration
The starter supports 66 options, which are listed below.
| Name | Description | Default | Type |
|---|---|---|---|
camel.component.netty-http.allow-serialized-headers | Only used for TCP when transferExchange is true. When set to true, serializable objects in headers and properties will be added to the exchange. Otherwise Camel will exclude any non-serializable objects and log it at WARN level. | false | Boolean |
camel.component.netty-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.netty-http.backlog | The maximum number of incoming connections that wait to be accepted by the TCP server (SO_BACKLOG). The operating system may limit it. When 0 (not set), Netty uses the SOMAXCONN value of the operating system. | Integer | |
camel.component.netty-http.boss-count | The number of threads of the boss EventLoopGroup, which accepts the connections of a TCP server. Not used when bossGroup is set. | 1 | Integer |
camel.component.netty-http.boss-group | An explicit EventLoopGroup to use as the boss group of a TCP server, which accepts the connections, for example to share it among several consumers. When not set, each consumer creates its own with bossCount threads. The option is a io.netty.channel.EventLoopGroup type. | EventLoopGroup | |
camel.component.netty-http.bridge-error-handler | Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored. | false | Boolean |
camel.component.netty-http.channel-group | An explicit Netty ChannelGroup in which a TCP server (consumer) or the producer keeps its open channels, and closes them when it stops. When not set, each creates its own. The option is a io.netty.channel.group.ChannelGroup type. | ChannelGroup | |
camel.component.netty-http.client-initializer-factory | A custom ClientInitializerFactory that builds the channel pipeline (handlers, encoders and decoders) of the producer, instead of the default one. The option is a org.apache.camel.component.netty.ClientInitializerFactory type. | ClientInitializerFactory | |
camel.component.netty-http.configuration | The configuration with the default settings of the endpoints that this component creates; each endpoint gets a copy of it. The option is a org.apache.camel.component.netty.NettyConfiguration type. | NettyConfiguration | |
camel.component.netty-http.connect-timeout | The time in milliseconds to wait for a TCP connection to the remote server to be established (the Netty CONNECT_TIMEOUT_MILLIS option), used by the producer and by a consumer in clientMode. 0 means no timeout. | 10000 | Integer |
camel.component.netty-http.correlation-manager | A custom NettyCamelStateCorrelationManager that matches each reply to its request, needed to send several requests concurrently over one channel (producerPoolEnabled=false): the requests and replies must carry a correlation id. Extending TimeoutCorrelationManagerSupport adds the handling of timeouts. The option is a org.apache.camel.component.netty.NettyCamelStateCorrelationManager type. | NettyCamelStateCorrelationManager | |
camel.component.netty-http.decoders | The decoders (Netty ChannelHandler) to add to the channel pipeline, as a comma-separated list of references to beans in the registry, each prefixed with #. | String | |
camel.component.netty-http.disconnect | Whether to close the channel after use: the producer closes it when the reply is received (or when the request is written, if sync is false), and the consumer closes it after it writes the reply. The CamelNettyCloseChannelWhenComplete header overrides it per message. | false | Boolean |
camel.component.netty-http.disconnect-on-no-reply | Whether the consumer closes the channel when sync is true and there is no reply to write back (the body is null), so the client does not wait for a reply. | true | Boolean |
camel.component.netty-http.enabled | Whether to enable auto configuration of the netty-http component. This is enabled by default. | Boolean | |
camel.component.netty-http.enabled-protocols | The SSL/TLS protocols to enable, as a comma-separated list. Not used when sslContextParameters is set. | TLSv1.2,TLSv1.3 | String |
camel.component.netty-http.encoders | The encoders (Netty ChannelHandler) to add to the channel pipeline, as a comma-separated list of references to beans in the registry, each prefixed with #. | String | |
camel.component.netty-http.executor-service | A custom Netty EventExecutorGroup that the consumers of this component use to route the messages when usingExecutorService is true, instead of the one that the component creates. The option is a io.netty.util.concurrent.EventExecutorGroup type. | EventExecutorGroup | |
camel.component.netty-http.header-filter-strategy | To use a custom org.apache.camel.spi.HeaderFilterStrategy to filter headers. The option is a org.apache.camel.spi.HeaderFilterStrategy type. | HeaderFilterStrategy | |
camel.component.netty-http.hostname-verification | To enable/disable hostname verification on SSLEngine | false | Boolean |
camel.component.netty-http.keep-alive | Whether to set the SO_KEEPALIVE socket option on TCP connections (the connections of the producer, and the ones a TCP server accepts), so the operating system sends keep-alive probes on an idle connection and notices a peer that is gone. netty-http also uses it as the default of the Connection header (keep-alive or close). | true | Boolean |
camel.component.netty-http.key-store-format | The type of the keystore and the truststore, such as JKS or PKCS12. Defaults to JKS if not set. | String | |
camel.component.netty-http.key-store-resource | The keystore with the key and certificate of this endpoint, used when ssl is true and sslContextParameters is not set. Is loaded by default from classpath, but you can prefix with classpath:, file:, or http: to load the resource from different systems. | String | |
camel.component.netty-http.lazy-channel-creation | Whether the producer opens its first connection when the first message is sent (true), or when it starts (false). With false, the producer fails to start when the remote server cannot be reached. | true | Boolean |
camel.component.netty-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.netty-http.maximum-pool-size | The number of threads of the EventExecutorGroup that the consumers of this component use to route the messages (see usingExecutorService). The group has at least one thread more than the Netty default event loop size (twice the number of CPU cores, or the io.netty.eventLoopThreads system property), so a smaller value has no effect. Not used when executorService is set. | Integer | |
camel.component.netty-http.mute-exception | If enabled and an Exchange failed processing on the consumer side the response written back to the remote peer won’t contain the exception’s class, message or stack trace. | true | Boolean |
camel.component.netty-http.native-transport | Whether to use a Netty native transport (epoll on Linux, kqueue on macOS and BSD) instead of NIO. The netty-transport-native-epoll or netty-transport-native-kqueue JAR for the operating system must be on the classpath; the endpoint fails to start when neither transport is available. | false | Boolean |
camel.component.netty-http.need-client-auth | Configures whether the server needs client authentication when using SSL. | false | Boolean |
camel.component.netty-http.netty-http-binding | To use a custom org.apache.camel.component.netty.http.NettyHttpBinding for binding to/from Netty and Camel Message API. The option is a org.apache.camel.component.netty.http.NettyHttpBinding type. | NettyHttpBinding | |
camel.component.netty-http.netty-server-bootstrap-factory | A custom NettyServerBootstrapFactory that the consumer starts instead of creating its own server bootstrap. The consumer does not initialize it, and serverInitializerFactory is then not used. Not used by netty-http. The option is a org.apache.camel.component.netty.NettyServerBootstrapFactory type. | NettyServerBootstrapFactory | |
camel.component.netty-http.no-reply-log-level | The logging level to use when there is nothing to send: on the consumer (if sync is enabled) when there is no reply to send back, and on the producer when the message has no body. | warn | LoggingLevel |
camel.component.netty-http.options | Additional Netty channel options, each set with the option. prefix and the name of a Netty ChannelOption constant, for example option.SO_LINGER=5. Only channel options with a boolean or integer value (such as SO_LINGER, SO_TIMEOUT, IP_TOS, IP_MULTICAST_TTL or WRITE_SPIN_COUNT) are recognized; other names are ignored. The producer sets them on the channels it opens (it skips the child. options). The consumer passes the values to Netty as text, which Netty rejects for these options, so the consumer fails to start. This is a multi-value option with prefix: option. | Object> | |
camel.component.netty-http.passphrase | Password to use for the keyStore and trustStore. The same password must be configured for both resources. | String | |
camel.component.netty-http.producer-pool-block-when-exhausted | Whether the producer waits for a free channel when the producer pool has producerPoolMaxTotal channels in use (true), or fails at once with a NoSuchElementException (false). producerPoolMaxWait sets how long it waits. | true | Boolean |
camel.component.netty-http.producer-pool-enabled | Whether the producer uses a pool of channels, one channel for each request in flight (true), or a single shared channel for all requests (false). With a shared channel and request-reply, the replies can come back out of order: you then need a correlationManager that matches each reply to its request by a correlation id in both messages. | true | Boolean |
camel.component.netty-http.producer-pool-max-idle | The maximum number of idle channels that the producer pool keeps; a channel given back to a full pool is closed. A negative value means no limit. | 100 | Integer |
camel.component.netty-http.producer-pool-max-total | The maximum number of channels (connections) in the producer pool, in use or idle. A negative value means no limit. Do not set it too low (such as 1): the pool needs room for a new channel, for example when a retry happens, and with producerPoolBlockWhenExhausted=true (the default) the producer then waits for a free channel, which can make the application hang. | -1 | Integer |
camel.component.netty-http.producer-pool-max-wait | The maximum time in milliseconds that the producer waits for a free channel when the producer pool is exhausted and producerPoolBlockWhenExhausted is true; it then fails with a NoSuchElementException. A negative value waits forever, and 0 fails at once. | -1 | Long |
camel.component.netty-http.producer-pool-min-evictable-idle | The time in milliseconds that a channel must be idle in the producer pool before the pool closes it (the pool checks every 30 seconds). 0 or a negative value keeps idle channels open. | 300000 | Long |
camel.component.netty-http.producer-pool-min-idle | The minimum number of idle channels that the producer pool keeps: every 30 seconds, the pool opens new connections to the remote server to keep this many. 0 keeps none. | Integer | |
camel.component.netty-http.receive-buffer-size | The size in bytes of the socket receive buffer (SO_RCVBUF). Only used for UDP. | 65536 | Integer |
camel.component.netty-http.receive-buffer-size-predictor | The size in bytes of the buffer that a UDP consumer allocates for each read (a Netty FixedRecvByteBufAllocator), which is the largest datagram it receives in full. When not set, Netty’s default of 2048 bytes applies. Only used by the UDP consumer. | Integer | |
camel.component.netty-http.request-timeout | The time in milliseconds that the producer waits for the reply of the remote server. It uses Netty’s ReadTimeoutHandler: the exchange fails with a ReadTimeoutException when no data is read on the channel within this time. 0 (the default) means no timeout. The CamelNettyRequestTimeout header overrides it per message. | Long | |
camel.component.netty-http.reuse-address | Whether to set the SO_REUSEADDR socket option, which allows binding to a local address and port that a previous socket still holds (such as a connection in TIME_WAIT), for example when a server restarts. | true | Boolean |
camel.component.netty-http.reuse-channel | Whether to use the same channel (connection) for the whole processing of an exchange. The producer keeps the channel in the CamelNettyChannel exchange property and uses it again when the same exchange is sent again, for example to call a server several times in one route. The channel goes back to the producer pool when the exchange is done, or is closed if disconnect is true. The consumer stores the channel of the received message in the same exchange property. | false | Boolean |
camel.component.netty-http.security-configuration | Refers to a org.apache.camel.component.netty.http.NettyHttpSecurityConfiguration for configuring secure web resources. The option is a org.apache.camel.component.netty.http.NettyHttpSecurityConfiguration type. | NettyHttpSecurityConfiguration | |
camel.component.netty-http.security-provider | The algorithm of the KeyManagerFactory and the TrustManagerFactory, such as SunX509 or PKIX. Defaults to SunX509 if not set. | String | |
camel.component.netty-http.send-buffer-size | The size in bytes of the socket send buffer (SO_SNDBUF). Only used for UDP. | 65536 | Integer |
camel.component.netty-http.server-closed-channel-exception-caught-log-level | If the server (NettyConsumer) catches an java.nio.channels.ClosedChannelException then its logged using this logging level. This is used to avoid logging the closed channel exceptions, as clients can disconnect abruptly and then cause a flood of closed exceptions in the Netty server. | debug | LoggingLevel |
camel.component.netty-http.server-exception-caught-log-level | The logging level at which the consumer logs the exceptions it catches, other than a java.nio.channels.ClosedChannelException (see serverClosedChannelExceptionCaughtLogLevel). | warn | LoggingLevel |
camel.component.netty-http.server-initializer-factory | A custom ServerInitializerFactory that builds the channel pipeline (handlers, encoders and decoders) of the consumer, instead of the default one. Not used by netty-http. The option is a org.apache.camel.component.netty.ServerInitializerFactory type. | ServerInitializerFactory | |
camel.component.netty-http.shutdown-timeout | The maximum time in milliseconds that a stopping TCP consumer waits for its channels to close and for each of its thread pools to shut down. It continues after that time without waiting further. | 100 | Integer |
camel.component.netty-http.ssl | Whether to use SSL/TLS on the connections of this endpoint. | false | Boolean |
camel.component.netty-http.ssl-client-cert-headers | When enabled and in SSL mode, then the Netty consumer will enrich the Camel Message with headers having information about the client certificate such as subject name, issuer name, serial number, and the valid date range. | false | Boolean |
camel.component.netty-http.ssl-context-parameters | The SSLContextParameters that configure SSL/TLS when ssl is true. The option is a org.apache.camel.support.jsse.SSLContextParameters type. | SSLContextParameters | |
camel.component.netty-http.ssl-handler | A custom Netty SslHandler to use when ssl is true, instead of the one that Camel creates. The option is a io.netty.handler.ssl.SslHandler type. | SslHandler | |
camel.component.netty-http.sync | Whether the endpoint uses request-reply (true) or one-way (false). With true the producer waits for the reply of the remote server, and the consumer writes the result of the route back as the reply. With false the producer does not wait for a reply, and the consumer sends none. | true | Boolean |
camel.component.netty-http.tcp-no-delay | Whether to set the TCP_NODELAY socket option on TCP connections, which turns off Nagle’s algorithm so small writes are sent at once instead of being combined. | true | Boolean |
camel.component.netty-http.transfer-exchange | Only used for TCP. You can transfer the exchange over the wire instead of just the body. The following fields are transferred: In body, Out body, fault body, In headers, Out headers, fault headers, exchange properties, exchange exception. This requires that the objects are serializable. Camel will exclude any non-serializable objects and log it at WARN level. The connection headers (CamelNettyRemoteAddress, CamelNettyLocalAddress, CamelNettyChannelHandlerContext, CamelNettySSLSession and the CamelNettySSLClientCert headers) and the CamelNettyRemoteAddress and CamelNettyChannel exchange properties are always the ones of the receiving side: the connection it accepted is the source of truth, and these values are never taken from the transferred exchange. | false | Boolean |
camel.component.netty-http.trust-store-resource | The truststore with the certificates that this endpoint trusts, used when ssl is true and sslContextParameters is not set. Is loaded by default from classpath, but you can prefix with classpath:, file:, or http: to load the resource from different systems. | String | |
camel.component.netty-http.unix-domain-socket-path | The path of a Unix domain socket that the TCP server (consumer) or the producer uses instead of a TCP socket. Host and port are still required, but are not used. Requires nativeTransport=true, and is not used with clientMode or UDP. | String | |
camel.component.netty-http.use-global-ssl-context-parameters | Enable usage of global SSL context parameters. | false | Boolean |
camel.component.netty-http.using-executor-service | Whether the consumer routes the messages on the threads of the EventExecutorGroup of the component (see maximumPoolSize and executorService), which keeps the messages of a channel in order and keeps the Netty event loop free when the route blocks. When false, the messages are routed on the Netty worker (event loop) threads. | true | Boolean |
camel.component.netty-http.worker-count | The number of threads of the worker EventLoopGroup, which does the I/O of the channels. When 0 (not set), Netty’s default applies: twice the number of CPU cores, or the value of the io.netty.eventLoopThreads system property. Not used when workerGroup is set. | Integer | |
camel.component.netty-http.worker-group | An explicit EventLoopGroup to use as the worker group, which does the I/O of the channels, for example to share it among several consumers and producers. When not set, each consumer and producer creates its own with workerCount threads. The option is a io.netty.channel.EventLoopGroup type. | EventLoopGroup |