blob: 3b4874c8ae38f3a70da02d50ffa0d1d9cae26a45 [file] [log] [blame]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html>
<head>
<link type="text/css" rel="stylesheet" href="/resources/site.css">
<script src='/resources/space.js'></script>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
<meta name="keywords" content="business integration, EAI, SOA, Service Oriented Architecture, web services, SOAP, JBI, JMS, WSDL, XML, EDI, Electronic Data Interchange, standards support, integration standards, application integration, middleware, software, solutions, services, CXF, open source">
<meta name="description" content="Apache CXF, Services Framework - Netty Configuration">
<link type="text/css" rel="stylesheet" href="/resources/highlighter/styles/shCoreCXF.css">
<link type="text/css" rel="stylesheet" href="/resources/highlighter/styles/shThemeCXF.css">
<script src='/resources/highlighter/scripts/shCore.js'></script>
<script src='/resources/highlighter/scripts/shBrushXml.js'></script>
<script src='/resources/highlighter/scripts/shBrushJava.js'></script>
<script>
SyntaxHighlighter.defaults['toolbar'] = false;
SyntaxHighlighter.all();
</script>
<title>
Apache CXF -- Netty Configuration
</title>
</head>
<body onload="init()">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td id="cell-0-0" colspan="2">&nbsp;</td>
<td id="cell-0-1">&nbsp;</td>
<td id="cell-0-2" colspan="2">&nbsp;</td>
</tr>
<tr>
<td id="cell-1-0">&nbsp;</td>
<td id="cell-1-1">&nbsp;</td>
<td id="cell-1-2">
<!-- Banner -->
<div class="banner" id="banner"><div><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td align="left" colspan="1" nowrap>
<a shape="rect" href="http://cxf.apache.org/" title="Apache CXF"><span style="font-weight: bold; font-size: 170%; color: white">Apache CXF</span></a>
</td><td align="right" colspan="1" nowrap>
<a shape="rect" href="http://www.apache.org/" title="The Apache Sofware Foundation"><img border="0" alt="ASF Logo" src="http://cxf.apache.org/images/asf-logo.png"></a>
</td></tr></table></div></div>
<!-- Banner -->
<div id="top-menu">
<table border="0" cellpadding="1" cellspacing="0" width="100%">
<tr>
<td>
<div align="left">
<!-- Breadcrumbs -->
<a href="index.html">Index</a>&nbsp;&gt;&nbsp;<a href="transports.html">Transports</a>&nbsp;&gt;&nbsp;<a href="http-transport.html">HTTP Transport</a>&nbsp;&gt;&nbsp;<a href="netty-configuration.html">Netty Configuration</a>
<!-- Breadcrumbs -->
</div>
</td>
<td>
<div align="right">
<!-- Quicklinks -->
<div id="quicklinks"><p><a shape="rect" href="http://cxf.apache.org/download.html">Download</a> | <a shape="rect" href="http://cxf.apache.org/docs/index.html">Documentation</a></p></div>
<!-- Quicklinks -->
</div>
</td>
</tr>
</table>
</div>
</td>
<td id="cell-1-3">&nbsp;</td>
<td id="cell-1-4">&nbsp;</td>
</tr>
<tr>
<td id="cell-2-0" colspan="2">&nbsp;</td>
<td id="cell-2-1">
<table>
<tr valign="top">
<td height="100%">
<div id="wrapper-menu-page-right">
<div id="wrapper-menu-page-top">
<div id="wrapper-menu-page-bottom">
<div id="menu-page">
<!-- NavigationBar -->
<div id="navigation"><ul class="alternate"><li><a shape="rect" href="overview.html">Overview</a></li><li><a shape="rect" href="how-tos.html">How-Tos</a></li><li><a shape="rect" href="frontends.html">Frontends</a></li><li><a shape="rect" href="databindings.html">DataBindings</a></li><li><a shape="rect" href="transports.html">Transports</a></li><li><a shape="rect" href="configuration.html">Configuration</a></li><li><a shape="rect" href="debugging-and-logging.html">Debugging and Logging</a></li><li><a shape="rect" href="tools.html">Tools</a></li><li><a shape="rect" href="restful-services.html">RESTful Services</a></li><li><a shape="rect" href="wsdl-bindings.html">WSDL Bindings</a></li><li><a shape="rect" href="service-routing.html">Service Routing</a></li><li><a shape="rect" href="dynamic-languages.html">Dynamic Languages</a></li><li><a shape="rect" href="ws-support.html">WS-* Support</a></li><li><a shape="rect" href="advanced-integration.html">Advanced Integration</a></li><li><a shape="rect" href="deployment.html">Deployment</a></li><li><a shape="rect" href="schemas-and-namespaces.html">Use of Schemas and Namespaces</a></li></ul><hr><ul class="alternate"><li><p>Search</p></li></ul><form enctype="application/x-www-form-urlencoded" method="get" id="cse-search-box" action="http://www.google.com/cse">
<div>
<input type="hidden" name="cx" value="002890367768291051730:o99qiwa09y4">
<input type="hidden" name="ie" value="UTF-8">
<input type="text" name="q" size="21">
<input type="submit" name="sa" value="Search">
</div>
</form>
<script type="text/javascript" src="http://www.google.com/cse/brand?form=cse-search-box&amp;lang=en"></script><hr><ul class="alternate"><li><a shape="rect" href="http://cxf.apache.org/javadoc/latest/">API 3.2.x (Javadoc)</a></li><li><a shape="rect" href="http://cxf.apache.org/javadoc/latest-3.1.x/">API 3.1.x (Javadoc)</a></li><li><a shape="rect" href="http://cxf.apache.org/">CXF Website</a></li></ul><p>&#160;</p><p><a shape="rect" class="external-link" href="http://www.apache.org/events/current-event.html"><span class="confluence-embedded-file-wrapper"><img class="confluence-embedded-image confluence-external-resource" src="http://www.apache.org/events/current-event-125x125.png" data-image-src="http://www.apache.org/events/current-event-125x125.png"></span></a></p></div>
<!-- NavigationBar -->
</div>
</div>
</div>
</div>
</td>
<td height="100%">
<!-- Content -->
<div class="wiki-content">
<div id="ConfluenceContent"><p><style type="text/css">/*<![CDATA[*/
div.rbtoc1636141734970 {padding: 0px;}
div.rbtoc1636141734970 ul {list-style: disc;margin-left: 0px;}
div.rbtoc1636141734970 li {margin-left: 0px;padding-left: 0px;}
/*]]>*/</style></p><div class="toc-macro rbtoc1636141734970">
<ul class="toc-indentation"><li><a shape="rect" href="#NettyConfiguration-ConfiguringtheNettyRuntime">Configuring the Netty Runtime</a>
<ul class="toc-indentation"><li><a shape="rect" href="#NettyConfiguration-Overview">Overview</a></li><li><a shape="rect" href="#NettyConfiguration-Namespace">Namespace</a></li><li><a shape="rect" href="#NettyConfiguration-Theengine-factoryelement">The engine-factory element</a></li><li><a shape="rect" href="#NettyConfiguration-Theengineelement">The engine element</a></li><li><a shape="rect" href="#NettyConfiguration-Configuringthethreadpool">Configuring the thread pool</a></li><li><a shape="rect" href="#NettyConfiguration-netty_http2HTTP/2support">HTTP/2 support</a></li><li><a shape="rect" href="#NettyConfiguration-Example">Example</a></li></ul>
</li></ul>
</div><h1 id="NettyConfiguration-ConfiguringtheNettyRuntime">Configuring the Netty Runtime</h1><h3 id="NettyConfiguration-Overview">Overview</h3><p>This section is for configuring the Netty runtime used for the CXF standalone model. The Netty runtime is used by HTTP servers and HTTP clients using a decoupled endpoint. The Netty runtime's thread pool, connector and timeouts can be configured. You can also set a number of the security settings for an HTTP service provider through the Netty runtime.</p><h3 id="NettyConfiguration-Namespace">Namespace</h3><p>The elements used to configure the Netty runtime are defined in the namespace <code><a shape="rect" href="http://cxf.apache.org/transports/http-netty-server/configuration">http://cxf.apache.org/transports/http-netty-server/configuration</a></code>. It is commonly referred to using the prefix <code>httpn</code>. In order to use the Betty configuration elements you will need to add the lines shown below to the <code>beans</code> element of your endpoint's configuration file. In addition, you will need to add the configuration elements' namespace to the <code>xsi:schemaLocation</code> attribute.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">&lt;beans ...
xmlns:httpn="http://cxf.apache.org/transports/http-netty-server/configuration
...
xsi:schemaLocation="...
http://cxf.apache.org/transports/http-netty-server/configuration
http://cxf.apache.org/schemas/configuration/http-netty-server.xsd
...&gt;</pre>
</div></div><h3 id="NettyConfiguration-Theengine-factoryelement">The <code>engine-factory</code> element</h3><p>The <code>httpn:engine-factory</code> 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.</p><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The value is typically <strong>cxf</strong> which is the name of the default <strong>Bus </strong>instance.</p></div></div><p>The <code>httpn:engine-factory</code> 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.</p><div class="table-wrap"><table class="wrapped confluenceTable"><colgroup span="1"><col span="1"><col span="1"></colgroup><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Element</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpn:engine</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the configuration for a particular Netty runtime instance.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpn:identifiedTLSServerParameters</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies a reusable set of properties for securing an HTTP server. It has a single attribute, <code>id</code>, that specifies a unique identifier by which the property set can be referred.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpn:identifiedThreadingParameters</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies a reusable set of properties for controlling a Netty instance's thread pool. It has a single attribute, <code>id</code>, that specifies a unique identifier by which the property set can be referred.</p></td></tr></tbody></table></div><h3 id="NettyConfiguration-Theengineelement">The <code>engine</code> element</h3><p>The <code>httpn:engine</code> element is used to configure specific instances of the Netty runtime. It has a single attribute, <code>port</code>, that specifies the number of the port being managed by the Netty instance.</p><div class="confluence-information-macro confluence-information-macro-tip"><span class="aui-icon aui-icon-small aui-iconfont-approve confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>You can specify a value of 0 for the port attribute. Any threading properties specified in an <code>httpn:engine</code> element with its port attribute set to 0 are used as the configuration for all Netty listeners that are not explicitly configured.</p></div></div><p>Each <code>httpn:engine</code> element can have two children: one for configuring security properties and one for configuring the Netty instance's thread pool. For each type of configuration you can either directly provide the configuration information or provide a reference to a set of configuration properties defined in the parent <code>httpn:engine-factory</code> element.</p><p>The child elements used to provide the configuration properties are described below.</p><div class="table-wrap"><table class="wrapped confluenceTable"><colgroup span="1"><col span="1"><col span="1"></colgroup><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Element</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpn:tlsServerParameters</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies a set of properties for configuring the security used for the specific Netty instance. See the <a shape="rect" href="https://cwiki.apache.org/confluence/display/CXF20DOC/TLS+Configuration">TLS Configuration</a> page for more information.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpn:tlsServerParametersRef</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Refers to a set of security properties defined by a <code>identifiedTLSServerParameters</code> element. The <code>id</code> attribute provides the id of the referred <code>identifiedTLSServerParameters</code> element.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpn:threadingParameters</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the size of the thread pool used by the specific Netty instance.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpn:threadingParametersRef</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Refers to a set of properties defined by a <code>identifiedThreadingParameters</code> element. The <code>id</code> attribute provides the id of the referred <code>identifiedThreadingParameters</code> element.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpn:sessionSupport</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If the value is true , the Netty Engine will set up a session manager for the Netty server engine to maintain the sessions. The default value of it is <strong>false</strong>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>httpn:reuseAddress</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The the value is true, the Netty Engine connector's socket will enable the SO_REUSEADDR flage. The default value of it is <strong>true</strong>.</p></td></tr></tbody></table></div><h3 id="NettyConfiguration-Configuringthethreadpool">Configuring the thread pool</h3><p>You can configure the size of a Netty instance's thread pool by either:</p><ul><li>Specifying the size of thread pool using a <code>identifiedThreadingParameters</code> element in the <code>engine-factory</code> element. You then refer to the element using a <code>threadingParametersRef</code> element.</li><li><p class="auto-cursor-target">Specify the size of the of thread pool directly using a <code>threadingParameters</code> element.<br clear="none">The <code>threadingParameters</code> has one attribute to specify the size of a thread pool. The attribute is described below.</p><div class="confluence-information-macro confluence-information-macro-warning"><span class="aui-icon aui-icon-small aui-iconfont-error confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The <code>httpn:identifiedThreadingParameters</code> element has a single child <code>threadingParameters</code> element</p></div></div></li></ul><div class="table-wrap"><table class="wrapped confluenceTable"><colgroup span="1"><col span="1"><col span="1"></colgroup><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh">Attribute</th><th colspan="1" rowspan="1" class="confluenceTh">Description</th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p>threadPoolSize</p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the number of threads available to the Netty instance for processing requests.</p></td></tr></tbody></table></div><h3 id="NettyConfiguration-netty_http2HTTP/2support"><span class="confluence-anchor-link" id="NettyConfiguration-netty_http2"></span>HTTP/2 support</h3><p>If <strong>HttpServerEngineSupport#ENABLE_HTTP2</strong>&#160; 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.</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">&lt;dependency&gt;
&lt;groupId&gt;io.netty&lt;/groupId&gt;
&lt;artifactId&gt;netty-codec-http2&lt;/artifactId&gt;
&lt;version&gt;${netty.version}&lt;/version&gt;
&lt;/dependency&gt;</pre>
</div></div><div class="confluence-information-macro confluence-information-macro-information"><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>Please be aware that if you configure HTTP/2 + TLS, CXF right now only supports JDK SSL provider.&#160;</p></div></div><p>Example: <a shape="rect" class="external-link" href="https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/basic_http2_netty" rel="nofollow">https://github.com/apache/cxf/tree/master/distribution/src/main/release/samples/jax_rs/basic_http2_netty</a></p><h3 id="NettyConfiguration-Example">Example</h3><p>The example below shows a configuration fragment that configures a Netty instance on port number 9001.</p><p><br clear="none"></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<pre class="brush: java; gutter: false; theme: Default">&lt;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"&gt;
&lt;httpn:engine-factory bus="cxf"&gt;
&lt;httpn:engine port="9001"&gt;
&lt;httpn:tlsServerParameters&gt;
&lt;sec:keyManagers keyPassword="skpass"&gt;
&lt;sec:keyStore file="src/main/config/serviceKeystore.jks" password="sspass" type="JKS"/&gt;
&lt;/sec:keyManagers&gt;
&lt;sec:trustManagers&gt;
&lt;sec:keyStore file="src/main/config/serviceKeystore.jks" password="sspass" type="JKS"/&gt;
&lt;/sec:trustManagers&gt;
&lt;/httpn:tlsServerParameters&gt;
&lt;/httpn:engine&gt;
&lt;/httpn:engine-factory&gt;
&lt;/beans&gt;</pre>
</div></div></div>
</div>
<!-- Content -->
</td>
</tr>
</table>
</td>
<td id="cell-2-2" colspan="2">&nbsp;</td>
</tr>
<tr>
<td id="cell-3-0">&nbsp;</td>
<td id="cell-3-1">&nbsp;</td>
<td id="cell-3-2">
<div id="footer">
<!-- Footer -->
<div id="site-footer">
<a href="http://cxf.apache.org/privacy-policy.html">Privacy Policy</a> -
(<a href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=191336279">edit page</a>)
(<a href="https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=191336279&amp;showComments=true&amp;showCommentArea=true#addcomment">add comment</a>)<br>
Apache CXF, CXF, Apache, the Apache feather logo are trademarks of The Apache Software Foundation.<br>
All other marks mentioned may be trademarks or registered trademarks of their respective owners.
</div>
<!-- Footer -->
</div>
</td>
<td id="cell-3-3">&nbsp;</td>
<td id="cell-3-4">&nbsp;</td>
</tr>
<tr>
<td id="cell-4-0" colspan="2">&nbsp;</td>
<td id="cell-4-1">&nbsp;</td>
<td id="cell-4-2" colspan="2">&nbsp;</td>
</tr>
</table>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-4458903-1");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>