第 18 章 配置 Remoting
18.1. 关于 Remoting 子系统
remoting 子系统允许您为本地和远程服务配置入站(inbound)和出站(outbound)连接,以及这些连接的设置。
JBoss Remoting 包括以下可配置的元素:端点(endpoint)、连接器(connector),以及一系列的本地和远程 URI。除非用户的应用程序需要使用自定义的连接器,用户一般不需要配置 remoting 子系统。那些需要作为远程客户端的应用程序(如 EJB)则需要独立的配置来连接到一个特定的连接器。
默认的 Remoting 子系统配置
<subsystem xmlns="urn:jboss:domain:remoting:3.0">
<endpoint/>
<http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
</subsystem>
如需获得 remoting 子系统可用的完整属性列表,请参阅 Remoting 子系统属性。
Remoting 端点
Remoting 端点使用了 io 子系统声明和配置的 XNIO 工作节点。
如需了解如何配置远程端点的信息,请参阅配置端点。
连接器
连接器是主要的 Remoting 配置元素。JBoss EAP 允许多个连接器。每个连接器都由带有几个子元素及其他一些属性的 <connector> 元素组成。默认的连接器被 JBoss EAP 的几个子系统使用。自定义连接器的元素和属性的专有设置取决于您的应用程序。更多信息请联系红帽全球支持服务。
如需了解如何配置连接器的信息,请参阅配置一个连接器。
出站连接
您可以指定三种不同类型的出站连接:
额外配置
Remoting 还依赖于 remoting 子系统以外的一些元素,如网络接口和 IO worker。
如需了解更多信息,请参阅额外的远程配置。
18.2. 配置端点
在 JBoss EAP 6 中,worker 线程池在 remoting 子系统中直接配置。在 JBoss EAP 7 中,remoting 端点配置会从 io 子系统中参考一个 worker。
JBoss EAP 默认提供下列端点配置。
<subsystem xmlns="urn:jboss:domain:remoting:3.0"> <endpoint/> ... </subsystem>
更新现有的端点配置
/subsystem=remoting/configuration=endpoint:write-attribute(name=authentication-retries,value=2)
重新载入
创建新的端点配置
/subsystem=remoting/configuration=endpoint:add
删除端点配置
/subsystem=remoting/configuration=endpoint:remove
重新载入
如需了解端点配置可用的属性,请参阅端点属性。
18.3. 配置连接器
连接器是和 Remoting 相关的主要配置元素,它包含几个用于其他配置的子元素。
更新现有的连接器配置
/subsystem=remoting/connector=new-connector:write-attribute(name=socket-binding,value=my-socket-binding)
重新载入
创建新的连接器
/subsystem=remoting/connector=new-connector:add(socket-binding=my-socket-binding)
删除连接器
/subsystem=remoting/connector=new-connector:remove
重新载入
关于配置连接器的可用属性的完整列表,请参考 Remoting 子系统属性章节。
18.4. 配置 HTTP 连接器
HTTP 连接器提供基于 HTTP Upgrade 的 Remoting 连接器的配置。JBoss EAP 默认提供了下列 http-connector 配置。
<subsystem xmlns="urn:jboss:domain:remoting:3.0">
...
<http-connector name="http-remoting-connector" connector-ref="default" security-realm="ApplicationRealm"/>
</subsystem>
在默认情况下,这个 HTTP connector 会连接到一个名为 default 的 HTTP listener 中(在 undertow 子系统中配置)。如需了解更多相关信息,请参阅配置 Web 服务器(Undertow)。
更新现有的 HTTP 连接器配置
/subsystem=remoting/http-connector=new-connector:write-attribute(name=connector-ref,value=new-connector-ref)
重新载入
创建新的 HTTP 连接器
/subsystem=remoting/http-connector=new-connector:add(connector-ref=default)
删除 HTTP 连接器
/subsystem=remoting/http-connector=new-connector:remove
如需了解配置一个 HTTP connector 的完整属性列表,请参阅连接器属性。
18.5. 配置出站连接
出站连接是一个由 URI 完全指定的通用 remoting 出站连接。
更新现有的出站连接
/subsystem=remoting/outbound-connection=new-outbound-connection:write-attribute(name=uri,value=http://example.com)
创建新的出站连接
/subsystem=remoting/outbound-connection=new-outbound-connection:add(uri=http://example.com)
删除出站连接
/subsystem=remoting/outbound-connection=new-outbound-connection:remove
如需了解配置一个出站连接的完整属性列表,请参阅出站连接属性。
18.6. 配置远程出站连接
远程出站连接是由协议、出站连接套接字绑定、用户名和安全区指定的。这个协议可以是 remote、http-remoting 或 https-remoting。
更新现有的远程出站连接
/subsystem=remoting/remote-outbound-connection=new-remote-outbound-connection:write-attribute(name=outbound-socket-binding-ref,value=outbound-socket-binding)
创建新的远程出站连接
/subsystem=remoting/remote-outbound-connection=new-remote-outbound-connection:add(outbound-socket-binding-ref=outbound-socket-binding)
删除远程出站连接
/subsystem=remoting/remote-outbound-connection=new-remote-outbound-connection:remove
如需了解配置一个远程出站连接的完整属性列表,请参阅远程出站连接属性。
18.7. 配置本地出站连接
本地出站连接是一个由转出套接字绑定指定的使用 local 协议的 Remoting 出站连接。
更新现有的本地出站连接
/subsystem=remoting/local-outbound-connection=new-local-outbound-connection:write-attribute(name=outbound-socket-binding-ref,value=outbound-socket-binding)
创建新的本地出站连接
/subsystem=remoting/local-outbound-connection=new-local-outbound-connection:add(outbound-socket-binding-ref=outbound-socket-binding)
删除本地出站连接
/subsystem=remoting/local-outbound-connection=new-local-outbound-connection:remove
如需了解配置一个本地出站连接的完整属性列表,请参阅本地出站连接属性。
18.8. 额外的远程配置
一些远程项需要在 remoting 子系统以外配置。
- IO worker
使用下列命令设置 Remoting 的 IO 工作节点:
/subsystem=remoting/configuration=endpoint:write-attribute(name=worker, value=WORKER_NAME)
如需了解如何配置一个 IO worker 的信息,请参阅配置工作节点。
- 网络接口
remoting子系统使用的网络接口是public,这个接口同时也被其它子系统使用,因此在需要修改它时请小心处理。<interfaces> <interface name="management"> <inet-address value="${jboss.bind.address.management:127.0.0.1}"/> </interface> <interface name="public"> <inet-address value="${jboss.bind.address:127.0.0.1}"/> </interface> <interface name="unsecure"> <inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/> </interface> </interfaces>在一个受管域中,每个主机在它的
host.xml文件中都定义了public接口。- 套接字绑定
remoting子系统使用的默认套接字绑定是绑定到端口8080。如需了解更多与套接字绑定和套接字绑定组相关的信息,请参阅套接字绑定。
- EJB 的远程 connector 参考
ejb3子系统包括了一个到远程 connector 的参考用来进行远程方法的调用。以下是默认的设置:<remote connector-ref="remoting-connector" thread-pool-name="default"/>
- 安全传输配置
如果客户有要求,Remoting 传输使用 STARTTLS 来保护连接安全,如 HTTPS、Secure Servlet。安全和非安全的连接使用相同的套接字绑定(网络端口),所以不需要额外的服务器端的配置。客户根据需要请求安全或非安全的传输方式。使用 Remoting 的 JBoss EAP 组件(如 EJB、ORB 和 JMS 供应商)都默认请求使用安全的接口。
警告STARTTLS 的工作方式是,当客户端请求一个安全连接时,它会激活一个安全连接,在其它情况下,都会使用一个未加密的连接。这就可能会导致“中间人(man-in-the-middle)”攻击:攻击者会截获客户端请求,然后把请求修改为请求一个未加密的连接。为了避免这个问题,客户端需要对接收到的连接进行检查。如果请求的是一个安全的连接,而返回的是一个未加密的连接,则需要进行相关的错误处理。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.