Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Configuring the Netty Runtime

...

The httpn:engine-factory element is the root element used to configure the Netty runtime used by an application. It has a single required attribute, bus, whose value is the name of the Bus that manages the Netty instances being configured.

Tip

The value is typically cxf which is the name of the default Bus instance.

The httpn:engine-factory element has three children that contain the information used to configure the HTTP ports instantiated by the Netty runtime factory. The children are described below.

...

  • Specifying the size of thread pool using a identifiedThreadingParameters element in the engine-factory element. You then refer to the element using a threadingParametersRef element.
  • Specify the size of the of thread pool directly using a threadingParameters element.
    The threadingParameters has one attribute to specify the size of a thread pool. The attribute is described below.

    Warning

    The httpjhttpn:identifiedThreadingParameters element has a single child threadingParameters element


AttributeDescription

threadPoolSize

Specifies the number of threads available to the Netty instance for processing requests.

Anchor
netty_http2
netty_http2
HTTP/2 support

If HttpServerEngineSupport#ENABLE_HTTP2  bus property is set, Netty engine will enable the HTTP/2 support as well: HTTP/2 over cleartext (h2c) if TLS is not configured, regular HTTP/2 otherwise. It requires additional dependencies to be bundled by the application.

Code Block
xml
xml
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-codec-http2</artifactId>
    <version>${netty.version}</version>
</dependency>


Info

Please be aware that if you configure HTTP/2 + TLS, CXF right now only supports JDK SSL provider. 

Example: https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/basic_http2_netty

Example

The example below shows a configuration fragment that configures a Netty instance on port number 9001.


Code Block
xml
xml
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:sec="http://cxf.apache.org/configuration/security"
    xmlns:http="http://cxf.apache.org/transports/http/configuration"
    xmlns:httpn="http://cxf.apache.org/transports/http-netty-server/configuration"
    xsi:schemaLocation="http://cxf.apache.org/configuration/security 
        http://cxf.apache.org/schemas/configuration/security.xsd 
        http://cxf.apache.org/transports/http/configuration 
        http://cxf.apache.org/schemas/configuration/http-conf.xsd 
        http://cxf.apache.org/transports/http-netty-server/configuration 
        http://cxf.apache.org/schemas/configuration/http-netty-server.xsd 
        http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans.xsd">
    <httpn:engine-factory bus="cxf">
        <httpn:engine port="9001">
            <httpn:tlsServerParameters>
                <sec:keyManagers keyPassword="skpass">
                    <sec:keyStore file="src/main/config/serviceKeystore.jks" password="sspass" type="JKS"/>
                </sec:keyManagers>
                <sec:trustManagers>
                    <sec:keyStore file="src/main/config/serviceKeystore.jks" password="sspass" type="JKS"/>
                </sec:trustManagers>
            </httpn:tlsServerParameters>
        </httpn:engine>
    </httpn:engine-factory>
</beans>