[hornetq-commits] JBoss hornetq SVN: r9053 - branches/HnetQ_323_cn/docs/user-manual/zh.
do-not-reply at jboss.org
do-not-reply at jboss.org
Sat Apr 3 11:34:46 EDT 2010
Author: gaohoward
Date: 2010-04-03 11:34:45 -0400 (Sat, 03 Apr 2010)
New Revision: 9053
Modified:
branches/HnetQ_323_cn/docs/user-manual/zh/configuring-transports.xml
Log:
one more chapter
Modified: branches/HnetQ_323_cn/docs/user-manual/zh/configuring-transports.xml
===================================================================
--- branches/HnetQ_323_cn/docs/user-manual/zh/configuring-transports.xml 2010-04-02 12:58:03 UTC (rev 9052)
+++ branches/HnetQ_323_cn/docs/user-manual/zh/configuring-transports.xml 2010-04-03 15:34:45 UTC (rev 9053)
@@ -17,18 +17,13 @@
<!-- permitted by applicable law. -->
<!-- ============================================================================= -->
<chapter id="configuring-transports">
- <title>Configuring the Transport</title>
- <para>HornetQ has a fully pluggable and highly flexible transport layer and defines its own
- Service Provider Interface (SPI) to make plugging in a new transport provider relatively
- straightforward.</para>
- <para>In this chapter we'll describe the concepts required for understanding HornetQ transports
- and where and how they're configured.</para>
+ <title>传输层的配置</title>
+ <para>HornetQ的传输层是“可插拔的”。通过灵活的配置和一套服务提供接口(SPI),HornetQ可以很容易地更换其传输层。</para>
+ <para>在本章中我们将对HornetQ的传输相关的概念作出解释,并说明它的配置方法。</para>
<section id="configuring-transports.acceptors">
- <title>Understanding Acceptors</title>
- <para>One of the most important concepts in HornetQ transports is the
- <emphasis>acceptor</emphasis>. Let's dive straight in and take a look at an acceptor
- defined in xml in the configuration file <literal
- >hornetq-configuration.xml</literal>.</para>
+ <title>接收器(Acceptor)</title>
+ <para>接收器(<emphasis>acceptor</emphasis>)是 HornetQ 的传输层中最为重要的概念之一。首先
+ 介绍一下在文件<literal>hornetq-configuration.xml</literal>中是怎样定义一个接收器的:</para>
<programlisting>
<acceptors>
<acceptor name="netty">
@@ -39,34 +34,22 @@
</acceptor>
</acceptors>
</programlisting>
- <para>Acceptors are always defined inside an <literal>acceptors</literal> element. There can
- be one or more acceptors defined in the <literal>acceptors</literal> element. There's no
- upper limit to the number of acceptors per server.</para>
- <para>Each acceptor defines a way in which connections can be made to the HornetQ
- server.</para>
- <para>In the above example we're defining an acceptor that uses <ulink
- url="http://jboss.org/netty">Netty</ulink> to listen for connections at port
- <literal>5446</literal>. </para>
- <para>The <literal>acceptor</literal> element contains a sub-element <literal
- >factory-class</literal>, this element defines the factory used to create acceptor
- instances. In this case we're using Netty to listen for connections so we use the Netty
- implementation of an <literal>AcceptorFactory</literal> to do this. Basically, the
- <literal>factory-class</literal> element determines which pluggable transport we're
- going to use to do the actual listening.</para>
- <para>The <literal>acceptor</literal> element can also be configured with zero or more
- <literal>param</literal> sub-elements. Each <literal>param</literal> element defines
- a key-value pair. These key-value pairs are used to configure the specific transport,
- the set of valid key-value pairs depends on the specific transport be used and are
- passed straight through to the underlying transport.</para>
- <para>Examples of key-value pairs for a particular transport would be, say, to configure the
- IP address to bind to, or the port to listen at.</para>
+ <para>所有接收器都在 <literal>acceptors</literal>单元(element)内定义。在<literal>acceptors</literal>
+ 内可以有零个或多个接收器的定义。每个服务器所拥有的接收器的数量是没有限制的。</para>
+ <para>每个接收器都要定义其与HornetQ服务器连接的方式。</para>
+ <para>以上的例子中我们定义了一个<ulink
+ url="http://jboss.org/netty">Netty</ulink>接收器。它在端口<literal>5446</literal>监听连接请求。</para>
+ <para>在<literal>acceptor</literal>单元内有一个子单元<literal>factory-class</literal>。这个单元是用来
+ 定义创建连接器的工厂类。一个连接器工厂类必须要实现<literal>AcceptorFactory</literal>接口。上例中我们定义
+ 的连接器工厂是类NettyAcceptorFactory使用Netty来建立连接。有个这个类定义,HornetQ就知道了用什么传输来建立连接了。</para>
+ <para>在<literal>acceptor</literal>中还可以配置零或多个参数<literal>param</literal>。在每个<literal>param</literal>
+ 中定义的是键-值对(key-value)。这些参数用来配置某个传输实现。不同传输有不同的配置参数。</para>
+ <para>像IP地址、端口号等都是传输配置参数的例子。</para>
</section>
<section id="understanding.connectors">
- <title>Understanding Connectors</title>
- <para>Whereas acceptors are used on the server to define how we accept connections,
- connectors are used by a client to define how it connects to a server.</para>
- <para>Let's look at a connector defined in our <literal>hornetq-configuration.xml</literal>
- file:</para>
+ <title>连接器(Connectors)</title>
+ <para>接收器定义的是如何在服务器端接收连接,而连接器则是定义客户端如何连接到服务器。</para>
+ <para>以下是<literal>hornetq-configuration.xml</literal>文件中一个连接器配置的例子。</para>
<programlisting>
<connectors>
<connector name="netty">
@@ -77,29 +60,24 @@
</connector>
</connectors>
</programlisting>
- <para>Connectors can be defined inside a <literal>connectors</literal> element. There can be
- one or more connectors defined in the <literal>connectors</literal> element. There's no
- upper limit to the number of connectors per server.</para>
- <para>You make ask yourself, if connectors are used by the <emphasis>client</emphasis> to
- make connections then why are they defined on the <emphasis>server</emphasis>? There are
- a couple of reasons for this:</para>
+ <para>连接器的配置在<literal>connectors</literal>单元中。可以定义一个或多个连接器。每个服务器配置的连接器
+ 数量是没有限制的。</para>
+ <para>你可能注意到了,既然连接器是定义<emphasis>客户端</emphasis>如何连接服务器的,那么为什么要定义在
+ <emphasis>服务器</emphasis>端呢?原因如下:</para>
<itemizedlist>
<listitem>
- <para>Sometimes the server acts as a client itself when it connects to another
- server, for example when one server is bridged to another, or when a server
- takes part in a cluster. In this cases the server needs to know how to connect
- to other servers. That's defined by <emphasis>connectors</emphasis>.</para>
+ <para>服务器有时也需要做为客户端去连接其它的服务器,比如当一个服务器通过桥连接到另一个服务器,或者是集群
+ 中服务器之间的互相通迅。在这种情况下服务器就要知道如何与另一台服务器建立连接。因此需要在
+ <emphasis>connectors</emphasis>下定义连接器。</para>
</listitem>
<listitem>
- <para>If you're using JMS and the server side JMS service to instantiate JMS
- ConnectionFactory instances and bind them in JNDI, then when creating the
- <literal>HornetQConnectionFactory</literal> it needs to know what server
- that connection factory will create connections to.</para>
- <para>That's defined by the <literal>connector-ref</literal> element in the <literal
- >hornetq-jms.xml</literal>file on the server side. Let's take a look at a
- snipped from a <literal>hornetq-jms.xml</literal> file that shows a JMS
- connection factory that references our netty connector defined in our <literal
- >hornetq-configuration.xml</literal> file:</para>
+ <para>如果你使用JMS服务,需要创建连接工厂的实例并绑定到JNDI。在HornetQ创建
+ <literal>HornetQConnectionFactory</literal>时需要连接器的必要信息,以便这个连接工厂
+ 能知道它如何与HornetQ服务器相连接。</para>
+ <para>这一信息被定义在配置文件<literal
+ >hornetq-jms.xml</literal>中的<literal>connector-ref</literal>单元下。下面这段配置
+ 就是从该配置文件中提取的相关部分,它展示了JMS的连接工厂是如何引用定义在配置文件<literal
+ >hornetq-configuration.xml</literal>中的连接器的:</para>
<programlisting>
<connection-factory name="ConnectionFactory">
<connectors>
@@ -115,18 +93,13 @@
</itemizedlist>
</section>
<section id="configuring-transports.client.side">
- <title>Configuring the transport directly from the client side.</title>
- <para>How do we configure a core <literal>ClientSessionFactory</literal> with the
- information that it needs to connect with a server?</para>
- <para>Connectors are also used indirectly when directly configuring a core <literal
- >ClientSessionFactory</literal> to directly talk to a server. Although in this case
- there's no need to define such a connector in the server side configuration, instead we
- just create the parameters and tell the <literal>ClientSessionFactory</literal> which
- connector factory to use.</para>
- <para>Here's an example of creating a <literal>ClientSessionFactory</literal> which will
- connect directly to the acceptor we defined earlier in this chapter, it uses the
- standard Netty TCP transport and will try and connect on port 5446 to localhost
- (default):</para>
+ <title>在客户端直接配置传输层</title>
+ <para>怎样配置一个内核<literal>ClientSessionFactory</literal>以让它知道如何连接服务器的信息呢?</para>
+ <para>在直接配置内核<literal>ClientSessionFactory</literal>的时候,可以间接地使用连接器。当然在这种情况
+ 下在服务器端定义连接器是没有意义的。我们通过将必要参数传给<literal>ClientSessionFactory</literal>的
+ 方法来告诉使用什么样的连接器工厂。</para>
+ <para>在下面的例子中,我们创建了一个<literal>ClientSessionFactory</literal>,它可以直接连接到我们先前定
+ 义的接收器上。它使用的是标准的Netty TCP传输层,连接主机是localhost(默认),端口5446:</para>
<programlisting>
Map<String, Object> connectionParams = new HashMap<String, Object>();
@@ -144,9 +117,8 @@
etc
</programlisting>
- <para>Similarly, if you're using JMS, you can configure the JMS connection factory directly
- on the client side without having to define a connector on the server side or define a
- connection factory in <literal>hornetq-jms.xml</literal>:</para>
+ <para>如果在客户端直接使用JMS的连接工厂的话,也可以用类似的方法而不需要在服务器端定义连接器或在
+ <literal>hornetq-jms.xml</literal>配置文件中创建连接工厂:</para>
<programlisting>
Map<String, Object> connectionParams = new HashMap<String, Object>();
@@ -165,182 +137,135 @@
</programlisting>
</section>
<section>
- <title>Configuring the Netty transport</title>
- <para>Out of the box, HornetQ currently uses <ulink url="http://www.jboss.org/netty/"
- >Netty</ulink>, a high performance low level network library.</para>
- <para>Our Netty transport can be configured in several different ways; to use old (blocking)
- Java IO, or NIO (non-blocking), also to use straightforward TCP sockets, SSL, or to
- tunnel over HTTP or HTTPS, on top of that we also provide a servlet transport.</para>
- <para>We believe this caters for the vast majority of transport requirements.</para>
+ <title>配置 Netty 传输层</title>
+ <para>HornetQ当前使用<ulink url="http://www.jboss.org/netty/"
+ >Netty</ulink>作为其默认的连接层。Netty是一个高性能的底层网络库.</para>
+ <para>Netty传输的配置有几种不同的方法。它可以使用传统的Java IO(阻塞方式)、NIO(非阻塞)或直接使用
+ TCP socket及SSL。或者使用HTTP或HTTPS协议。同时还可能使用servlet进行传输。</para>
+ <para>采用Netty应该能满足绝大部分的传输要求。</para>
<section>
- <title>Configuring Netty TCP</title>
- <para>Netty TCP is a simple unencrypted TCP sockets based transport. Netty TCP can be
- configured to use old blocking Java IO or non blocking Java NIO. We recommend you
- use the Java NIO on the server side for better scalability with many concurrent
- connections. However using Java old IO can sometimes give you better latency than
- NIO when you're not so worried about supporting many thousands of concurrent
- connections. </para>
- <para>If you're running connections across an untrusted network please bear in mind this
- transport is unencrypted. You may want to look at the SSL or HTTPS
- configurations.</para>
- <para>With the Netty TCP transport all connections are initiated from the client side.
- I.e. the server does not initiate any connections to the client. This works well
- with firewall policies that typically only allow connections to be initiated in one
- direction.</para>
- <para>All the valid Netty transport keys are defined in the class <literal
- >org.hornetq.integration.transports.netty.TransportConstants</literal>. The
- parameters can be used either with acceptors or connectors. The following parameters
- can be used to configure Netty for simple TCP:</para>
+ <title>配置 Netty TCP</title>
+ <para>Netty TCP 是简单的非加密的基于TCP socket的传输。它可以使用阻塞式的Java IO或非阻塞式的Java NIO。
+ 我们建议在服务器端采用非阻塞式的NIO以获得良好的并发处理能力。当并发能力并不是很重要时,可以使用阻塞式
+ 的方式以增加响应的速度。</para>
+ <para>如果你的应用是运行在不信任的网络上,你应该选择使用SSL或HTTPS。</para>
+ <para>Netty TCP的所有连接都是从客户端发起的。服务器端不向客户端发起任何连接。在有防火墙的环境中,这种方式
+ 是比较适合的。因为防火墙只允许单方向的连接。</para>
+ <para>在<literal>org.hornetq.integration.transports.netty.TransportConstants</literal>类中定义了所
+ 有的配置参数的名称(key)。它们既用于配置接收器以用于配置连接器。下面列出的参数用以配置一个简单的Netty TCP:</para>
<itemizedlist>
<listitem>
- <para><literal>use-nio</literal>. If this is <literal>true</literal> then Java
- non blocking NIO will be used. If set to <literal>false</literal> than old
- blocking Java IO will be used.</para>
- <para>We highly recommend that you use non blocking Java NIO. Java NIO does not
- maintain a thread per connection so can scale to many more concurrent
- connections than with old blocking IO. We recommend the usage of Java 6 for
- NIO and the best scalability. The default value for this property is
- <literal>true</literal> on the server side and <literal>false</literal>
- on the client side.</para>
+ <para><literal>use-nio</literal>。如果设为<literal>true</literal>则使用非阻塞的Java
+ NIO。如果<literal>false</literal>则使用传统的阻塞方式的Java IO。</para>
+ <para>我们建议使用Java NIO。因为Java NIO不是为每一个连接分配一个线程,所以它要比传统的阻塞式
+ Java IO具有更强的并发连接的处理能力。另外我们还建议使用Java 6的NIO以获得最佳性能。这个参
+ 数的默认值在服务器端是<literal>true</literal>,在客户端是<literal>false</literal>。
</listitem>
<listitem>
- <para><literal>host</literal>. This specifies the host name or IP address to
- connect to (when configuring a connector) or to listen on (when configuring
- an acceptor). The default value for this property is <literal
- >localhost</literal>. When configuring acceptors, multiple hosts or IP
- addresses can be specified by separating them with commas. It is also
- possible to specify <code>0.0.0.0</code> to accept connection from all the
- host's network interfaces. It's not valid to specify multiple addresses when
- specifying the host for a connector; a connector makes a connection to one
- specific address.</para>
+ <para><literal>host</literal>。主机名或IP地址。对于接收器来说,它是服务器接收连接的地址。
+ 对于连接器端,它是客户端连接的目标地址。默认值是<literal>localhost</literal>。
+ 在配置接收器时可以指定多个主机名或IP地址,中间用逗号隔开。如果指定的主机是<code>0.0.0.0</code>,
+ 则接收器将从主机上所有的网络接口中接受连接请求。连接器不允许指定多个主机地址,它只能与一个
+ 地址建立连接。</para>
<note>
- <para>Don't forget to specify a host name or ip address! If you want your
- server able to accept connections from other nodes you must specify a
- hostname or ip address at which the acceptor will bind and listen for
- incoming connections. The default is localhost which of course is not
- accessible from remote nodes!</para>
+ <para>一定不要忘记指定一个主机名或IP地址!一个服务器要想接受来自其它节点的连接就必需有一个
+ 主机名或IP地址来绑定及监听外部的连接请求。默认的主机名localhost是不能接受外部的
+ 连接请求的!</para>
</note>
</listitem>
<listitem>
- <para><literal>port</literal>. This specified the port to connect to (when
- configuring a connector) or to listen on (when configuring an acceptor). The
- default value for this property is <literal>5445</literal>.</para>
+ <para><literal>port</literal>。连接的端口。用于配置连接器或接收器。连接器用此端口来建立
+ 连接。接收器在些端口上监听连接请求。默认值是<literal>5445</literal>。</para>
</listitem>
<listitem>
- <para><literal>tcp-no-delay</literal>. If this is <literal>true</literal> then
- <ulink url="http://en.wikipedia.org/wiki/Nagle's_algorithm">Nagle's
- algorithm</ulink> will be enabled. The default value for this property
- is <literal>true</literal>.</para>
+ <para><literal>tcp-no-delay</literal>。将它设为<literal>true</literal>就会使用
+ <ulink url="http://en.wikipedia.org/wiki/Nagle's_algorithm">Nagle
+ 算法</ulink>.默认值是<literal>true</literal>。</para>
</listitem>
<listitem>
- <para><literal>tcp-send-buffer-size</literal>. This parameter determines the size
- of the TCP send buffer in bytes. The default value for this property is
- <literal>32768</literal> bytes (32KiB).</para>
- <para>TCP buffer sizes should be tuned according to the bandwidth and latency of
- your network. Here's a good link that explains the theory behind <ulink
- url="http://www-didc.lbl.gov/TCP-tuning/">this</ulink>.</para>
- <para>In summary TCP send/receive buffer sizes should be calculated as:</para>
+ <para><literal>tcp-send-buffer-size</literal>。这个参数指定了TCP的发送缓冲大小,单位是字节。
+ 默认值是<literal>32768</literal>字节(32KiB)。</para>
+ <para>这个参数要根据你的网络的带宽与时延的情况而调整。<ulink url="http://www-didc.lbl.gov/TCP-tuning/">
+ 这个链接</ulink>对此有很好的论述。</para>
+ <para>简言之,TCP的发送/接收缓冲的大小可以用下面公式来计算:</para>
<programlisting>
- buffer_size = bandwidth * RTT.
+ 缓冲大小 = 带宽 * RTT
</programlisting>
- <para>Where bandwidth is in <emphasis>bytes per second</emphasis> and network
- round trip time (RTT) is in seconds. RTT can be easily measured using the
- <literal>ping</literal> utility.</para>
- <para>For fast networks you may want to increase the buffer sizes from the
- defaults.</para>
+ <para>其中带宽的单位是 <emphasis>每秒字节数</emphasis>,RTT(网络往返程时间)的单位是秒。
+ 使用<literal>ping</literal>工具可以方便地测量出RTT。</para>
+ <para>对于快速网络可以适当加大缓冲的大小。</para>
</listitem>
<listitem>
- <para><literal>tcp-receive-buffer-size</literal>. This parameter determines the
- size of the TCP receive buffer in bytes. The default value for this property
- is <literal>32768</literal> bytes (32KiB).</para>
+ <para><literal>tcp-receive-buffer-size</literal>。这个参数指定了TCP接收缓冲的大小,单位是字节。
+ 默认值是<literal>32768</literal>字节(32KiB)。</para>
</listitem>
</itemizedlist>
</section>
<section>
- <title>Configuring Netty SSL</title>
- <para>Netty SSL is similar to the Netty TCP transport but it provides additional
- security by encrypting TCP connections using the Secure Sockets Layer SSL</para>
- <para>Please see the examples for a full working example of using Netty SSL.</para>
- <para>Netty SSL uses all the same properties as Netty TCP but adds the following
- additional properties:</para>
+ <title>配置Netty SSL</title>
+ <para>Netty SSL的配置与Netty TCP相似。它采用了安全套接字层(SSL)来提供加密的TCP连接。</para>
+ <para>我们提供了一个Netty SSL的例子来演示其配置和应用。</para>
+ <para>Netty SSL拥有Netty TCP一样的参数,另外还有下列的附加参数:</para>
<itemizedlist>
<listitem>
- <para><literal>ssl-enabled</literal>. Must be <literal>true</literal> to enable
- SSL.</para>
+ <para><literal>ssl-enabled</literal>。必须设为<literal>true</literal>以使用SSL。</para>
</listitem>
<listitem>
- <para><literal>key-store-path</literal>. This is the path to the SSL key store on
- the client which holds the client certificates.</para>
+ <para><literal>key-store-path</literal>。存放SSL密钥的路径(key store)。这是存放客户端证书的地方。</para>
</listitem>
<listitem>
- <para><literal>key-store-password</literal>. This is the password for the client
- certificate key store on the client.</para>
+ <para><literal>key-store-password</literal>。用于访问key store的密码。</para>
</listitem>
<listitem>
- <para><literal>trust-store-path</literal>. This is the path to the trusted client
- certificate store on the server.</para>
+ <para><literal>trust-store-path</literal>。服务器端存放可信任客户证书的路径。</para>
</listitem>
<listitem>
- <para><literal>trust-store-password</literal>. This is the password to the trusted
- client certificate store on the server.</para>
+ <para><literal>trust-store-password</literal>。用于访问可信任客户证书(trust store)的密码。</para>
</listitem>
</itemizedlist>
</section>
<section>
- <title>Configuring Netty HTTP</title>
- <para>Netty HTTP tunnels packets over the HTTP protocol. It can be useful in scenarios
- where firewalls only allow HTTP traffice to pass.</para>
- <para>Please see the examples for a full working example of using Netty HTTP.</para>
- <para>Netty HTTP uses the same properties as Netty TCP but adds the following additional
- properties:</para>
+ <title>配置Netty HTTP</title>
+ <para>Netty HTTP 通过HTTP通道传送数据包。在有些用户环境中防火墙只允许有HTTP通信,这时采用Netty HTTP作为HornetQ
+ 的传输层就能解决问题。</para>
+ <para>我们提供了一个Netty HTTP的例子来演示其配置和应用。</para>
+ <para>Netty HTTP具有和Netty TCP同样的配置参数,另外它还有以下参数:</para>
<itemizedlist>
<listitem>
- <para><literal>http-enabled</literal>. Must be <literal>true</literal> to enable
- HTTP.</para>
+ <para><literal>http-enabled</literal>。如果要使用HTTP,这个参数必须设为<literal>true</literal>。</para>
</listitem>
<listitem>
- <para><literal>http-client-idle-time</literal>. How long a client can be idle
- before sending an empty http request to keep the connection alive</para>
+ <para><literal>http-client-idle-time</literal>。客户端空闲时间。如果客户端的空闲时间超过
+ 这个值,Netty就会发送一个空的HTTP请求以保持连接不被关闭。</para>
</listitem>
<listitem>
- <para><literal>http-client-idle-scan-period</literal>. How often, in milliseconds,
- to scan for idle clients</para>
+ <para><literal>http-client-idle-scan-period</literal>。扫描空闲客户端的间隔时间。单位是毫秒。</para>
</listitem>
<listitem>
- <para><literal>http-response-time</literal>. How long the server can wait before
- sending an empty http response to keep the connection alive</para>
+ <para><literal>http-response-time</literal>。服务器端向客户端发送空的http响应前的最大等待时间。</para>
</listitem>
<listitem>
- <para><literal>http-server-scan-period</literal>. How often, in milliseconds, to
- scan for clients needing responses</para>
+ <para><literal>http-server-scan-period</literal>。服务器扫描需要响应的客户端的时间间隔。单位是毫秒。</para>
</listitem>
<listitem>
- <para><literal>http-requires-session-id</literal>. If true the client will wait
- after the first call to receive a session id. Used the http connector is
- connecting to servlet acceptor (not recommended) </para>
+ <para><literal>http-requires-session-id</literal>。如果设为true,客户端在第一次请求后将等待
+ 接收一个会话ID。http 连接器用它来连接servlet接收器(不建议这样使用)。</para>
</listitem>
</itemizedlist>
</section>
<section>
- <title>Configuring Netty Servlet</title>
- <para>We also provide a Netty servlet transport for use with HornetQ. The servlet
- transport allows HornetQ traffic to be tunneled over HTTP to a servlet running in a
- servlet engine which then redirects it to an in-VM HornetQ server.</para>
- <para>The servlet transport differs from the Netty HTTP transport in that, with the HTTP
- transport HornetQ effectively acts a web server listening for HTTP traffic on, e.g.
- port 80 or 8080, whereas with the servlet transport HornetQ traffic is proxied
- through a servlet engine which may already be serving web site or other
- applications. This allows HornetQ to be used where corporate policies may only allow
- a single web server listening on an HTTP port, and this needs to serve all
- applications including messaging.</para>
- <para>Please see the examples for a full working example of the servlet transport being
- used.</para>
- <para>To configure a servlet engine to work the Netty Servlet transport we need to do
- the following things:</para>
+ <title>配置Netty Servlet</title>
+ <para>HornetQ可以使用Netty servlet来传输消息。使用servlet可以将HornetQ的数据通过HTTP传送到一个
+ 运行的servlet,再由servlet转发给HornetQ服务器。</para>
+ <para>servlet与HTTP的不同之处在于,当用HTTP传输时,HornetQ如同一个web服务器,它监听在某个端口上的HTTP
+ 请求并返回响应。比如80端口或8080端口。而当使用servlet时,HornetQ的传输数据是通过运行在某一servlet容器
+ 中的一个特定的servlet来转发的。而这个sevlet容器中同时还可能运行其他的应用,如web服务。当一个公司有多个应用
+ 但只允许一个http端口可以访问时,servlet传输可以很好的解决HornetQ的传输问题。</para>
+ <para>请参见HornetQ所提供的servlet例子来了解详细的配置方法。</para>
+ <para>要在HornetQ中使用Netty servlet传输方式,需要以下步骤:</para>
<itemizedlist>
<listitem>
- <para>Deploy the servlet. Here's an example web.xml describing a web application
- that uses the servlet:</para>
+ <para>部署servlet。下面是一个web.xml例子:</para>
<programlisting><?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
@@ -364,10 +289,8 @@
</programlisting>
</listitem>
<listitem>
- <para>We also need to add a special Netty invm acceptor on the server side
- configuration.</para>
- <para>Here's a snippet from the <literal>hornetq-configuration.xml</literal>
- file showing that acceptor being defined:</para>
+ <para>我们还需要在服务器端加上一个特殊的Netty invm 接收器。</para>
+ <para>下面是从<literal>hornetq-configuration.xml</literal>配置文件中摘取的定义接收器的配置部分:</para>
<programlisting>
<acceptors>
@@ -383,8 +306,7 @@
</programlisting>
</listitem>
<listitem>
- <para>Lastly we need a connector for the client, this again will be configured
- in the <literal>hornetq-configuration.xml</literal> file as such:</para>
+ <para>最后我们需要在客户端配置连接器,也是在<literal>hornetq-configuration.xml</literal>文件中来做。如下所示:</para>
<programlisting><connectors>
<connector name="netty-servlet">
@@ -400,21 +322,16 @@
</connectors></programlisting>
</listitem>
</itemizedlist>
- <para>Heres a list of the init params and what they are used for</para>
+ <para>下面列出了初始化参数以及它们的用途:</para>
<itemizedlist>
<listitem>
- <para>endpoint - This is the name of the netty acceptor that the servlet will
- forward its packets too. You can see it matches the name of the <literal
- >host</literal> param.</para>
+ <para>endpoint - Netty接收器的名字。servlet将向它转发数据包。它与<literal
+ >host</literal>参数的值是对应的。</para>
</listitem>
</itemizedlist>
- <para>The servlet pattern configured in the <literal>web.xml</literal> is the path of
- the URL that is used. The connector param <literal>servlet-path</literal> on the
- connector config must match this using the application context of the web app if
- there is one.</para>
- <para>Its also possible to use the servlet transport over SSL. simply add the following
- configuration to the
- connector:<programlisting> <connector name="netty-servlet">
+ <para>在<literal>web.xml</literal>中定义的servlet的URL形式与在连接器配置文件中定义的
+ <literal>servlet-path</literal>值应该相匹配。</para>
+ <para>servlet可以与SSL一起使用。只需要在连接器配置中加上下面的配置即可:<programlisting> <connector name="netty-servlet">
<factory-class>org.hornetq.integration.transports.netty.NettyConnectorFactory</factory-class>
<param key="host" value="localhost"/>
<param key="port" value="8443"/>
@@ -425,19 +342,14 @@
<param key="key-store-password" value="keystore password"/>
</connector>
</programlisting></para>
- <para>You will also have to configure the Application server to use a KeyStore. Edit the
- <literal>server.xml</literal> file that can be found under <literal
- >server/default/deploy/jbossweb.sar</literal> of the Application Server
- installation and edit the SSL/TLS connector configuration to look like the
- following:<programlisting><Connector protocol="HTTP/1.1" SSLEnabled="true"
+ <para>另外你还需要为服务器指定一个KeyStore。打开<literal>server/default/deploy/jbossweb.sar</literal>
+ 下的<literal>server.xml</literal>文件,按照下面的内容编辑其中的SSL/TLS连接器配置:<programlisting><Connector protocol="HTTP/1.1" SSLEnabled="true"
port="8443" address="${jboss.bind.address}"
scheme="https" secure="true" clientAuth="false"
keystoreFile="path to a keystore"
keystorePass="keystore password" sslProtocol = "TLS" />
-</programlisting>In
- both cases you will need to provide a keystore and password. Take a look at the
- servlet ssl example shipped with HornetQ for more detail.</para>
+</programlisting>SSL需要keystore和访问密码。参见servlet ssl例子以了解更多的有关信息。</para>
</section>
</section>
</chapter>
More information about the hornetq-commits
mailing list