Menu Close
12.4. Undertow ランタイムの設定
概要
Undertow ランタイムは、分離されたエンドポイントを使用する HTTP サービスプロバイダーと HTTP コンシューマーによって使用されます。ランタイムのスレッドプールを設定できます。また、Undertow ランタイムを使用して HTTP サービスプロバイダーのセキュリティー設定を複数設定することもできます。
Maven 依存関係
Apache Maven をビルドシステムとして使用する場合は、プロジェクトの pom.xml
ファイルに以下の依存関係を追加して、Undertow ランタイムをプロジェクトに追加できます。
<dependency> <groupId>org.apache.cxf</groupId> <artifactId>cxf-rt-transports-http-undertow</artifactId> <version>${cxf-version}</version> </dependency>
namespace
Undertow ランタイムの設定に使用される要素は、namespace http://cxf.apache.org/transports/http-undertow/configuration で定義されます。Undertow 設定要素を使用するには、例12.14「Undertow ランタイム設定 namespace」 にある行をエンドポイント設定ファイルの beans
要素に追加する必要があります。この例では、namespace にプレフィックス httpu が割り当てられます。また、設定要素の namespace を xsi:schemaLocation
属性に追加する必要があります。
例12.14 Undertow ランタイム設定 namespace
<beans ... xmlns:httpu="http://cxf.apache.org/transports/http-undertow/configuration" ... xsi:schemaLocation="... http://cxf.apache.org/transports/http-undertow/configuration http://cxf.apache.org/schemas/configuration/http-undertow.xsd ...">
engine-factory 要素
httpu:engine-factory
要素は、アプリケーションによって使用される Undertow ランタイムの設定に使用されるルート要素です。この属性には単一の必須属性 bus
があり、その値は、設定されている Undertow インスタンスを管理する Bus
の名前です。
値は通常、デフォルトの Bus
インスタンスの名前である cxf
です。
http:engine-factory
要素には、Undertow ランタイムファクトリーによってインスタンス化された HTTP ポートの設定に使用される情報が含まれる 3 つの子があります。子は 表12.7「Undertow ランタイムファクトリーを設定するための要素」 に記載されています。
表12.7 Undertow ランタイムファクトリーを設定するための要素
要素 | 説明 |
---|---|
| 特定の Undertow ランタイムインスタンスの設定を指定します。「engine 要素」 を参照してください。 |
HTTP サービスプロバイダーを保護するための再利用可能なプロパティーのセットを指定します。これには、プロパティーセットを参照できる一意な識別子を指定する単一の属性 | |
Undertow インスタンスのスレッドプールを制御するための再利用可能なプロパティーセットを指定します。これには、プロパティーセットを参照できる一意な識別子を指定する単一の属性 「スレッドプールの設定」 を参照してください。 |
engine 要素
httpu:engine
要素は、Undertow ランタイムの特定のインスタンスを設定するために使用されます。これには、Undertow インスタンスによって管理されるポートの数を指定する単一の属性 port
があります。
port
属性の 0
の値を指定できます。port
属性が 0
に設定された httpu:engine
要素に指定されたスレッド化プロパティーは、明示的に設定されていないすべての Undertow リスナーの設定として使用されます。
各 httpu:engine
要素には 2 つの子を設定できます。1 つはセキュリティープロパティーの設定用で、もう 1 つは Undertow インスタンスのスレッドプールの設定用です。各種類の設定に対して、設定情報を直接提供するか、親の httpu:engine-factory
要素で定義された設定プロパティーのセットへの参照を提供できます。
設定プロパティーを提供するために使用される子要素については、表12.8「Undertow ランタイムインスタンスを設定するための要素」 を参照してください。
表12.8 Undertow ランタイムインスタンスを設定するための要素
要素 | 説明 |
---|---|
特定の Undertow インスタンスに使用されるセキュリティーを設定するためのプロパティーセットを指定します。 | |
| |
特定の Undertow インスタンスによって使用されるスレッドプールのサイズを指定します。「スレッドプールの設定」 を参照してください。 | |
|
スレッドプールの設定
Undertow インスタンスのスレッドプールのサイズは、次のいずれかの方法で設定できます。
-
engine-factory
要素のidentifiedThreadingParameters
要素を使用してスレッドプールのサイズを指定します。その後、threadingParametersRef
要素を使用して要素を参照します。 -
threadingParameters
要素を使用して、スレッドプールのサイズを直接指定します。
threadingParameters
には、スレッドプールのサイズを指定する属性が 2 つあります。属性は 表12.9「Undertow スレッドプールを設定するための属性」 に記載されています。
httpu:identifiedThreadingParameters
要素には単一の子要素 threadingParameters
があります。
例
例12.15「Undertow インスタンスの設定」 は、ポート番号 9001 で Undertow インスタンスを設定する設定フラグメントを示しています。
例12.15 Undertow インスタンスの設定
<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:httpu="http://cxf.apache.org/transports/http-undertow/configuration" xmlns:jaxws="http://java.sun.com/xml/ns/jaxws" 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-undertow/configuration http://cxf.apache.org/schemas/configuration/http-undertow.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd"> ... <httpu:engine-factory bus="cxf"> <httpu:identifiedTLSServerParameters id="secure"> <sec:keyManagers keyPassword="password"> <sec:keyStore type="JKS" password="password" file="certs/cherry.jks"/> </sec:keyManagers> </httpu:identifiedTLSServerParameters> <httpu:engine port="9001"> <httpu:tlsServerParametersRef id="secure" /> <httpu:threadingParameters minThreads="5" maxThreads="15" /> </httpu:engine> </httpu:engine-factory> </beans>
同時要求およびキューサイズの制限
同時接続リクエストの最大数の制限を設定する Request Limiting Handler と、Undertow サーバーインスタンスで処理できるキューサイズを設定できます。この設定の例を 例12.16「接続要求およびキューサイズの制限」 に示します。
表12.10 Request Limiting Handler を設定するための属性
例12.16 接続要求およびキューサイズの制限
<httpu:engine-factory> <httpu:engine port="8282"> <httpu:handlers> <bean class="org.jboss.fuse.quickstarts.cxf.soap.CxfRequestLimitingHandler"> <property name="maximumConcurrentRequests" value="1" /> <property name="queueSize" value="1"/> </bean> </httpu:handlers> </httpu:engine> </httpu:engine-factory>