blob: e469dfb8bb12e0c275de97a52fdfc436da26a0c5 [file] [log] [blame]
<div class="wiki-content maincontent"><h3 id="TCPTransportReference-TheTCPTransport">The TCP Transport</h3><p>The TCP transport allows clients to connect to a remote ActiveMQ broker using a TCP socket. These configuration options can be used to tune the underlying TCP transport on either the client-side using the JMS client's connection URI string or on a broker's transport connector URI.</p><div class="confluence-information-macro confluence-information-macro-information"><p class="title">Use Correct Prefix!</p><span class="aui-icon aui-icon-small aui-iconfont-info confluence-information-macro-icon"></span><div class="confluence-information-macro-body"><p>The options below should be prefixed with <code><strong>transport.*</strong></code> when used on a broker's transport connector definition. On the client-side, however, the <strong><code>transport.*</code></strong> prefix <em>must</em> be omitted.</p></div></div><h4 id="TCPTransportReference-ConfigurationSyntax">Configuration Syntax</h4><p><code><strong>tcp://hostname:port?key=value</strong></code></p><h5 id="TCPTransportReference-Examples">Examples</h5><p>Broker side (in&#160;<strong><code>TransportConnector</code></strong>):</p><div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>tcp://localhost:61616?transport.threadName&amp;transport.trace=false&amp;transport.soTimeout=60000
</pre>
</div></div><p>Client side (in&#160;<strong><code>brokerURL</code></strong>):</p><div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent panelContent">
<pre>tcp://localhost:61616?threadName&amp;trace=false&amp;soTimeout=60000
</pre>
</div></div><h5 id="TCPTransportReference-TransportOptions">Transport Options</h5><div class="table-wrap"><table class="confluenceTable"><tbody><tr><th colspan="1" rowspan="1" class="confluenceTh"><p>Option Name</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Default Value</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>backlog</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>5000</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the maximum number of connections waiting to be accepted by the transport server socket.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>closeAsync</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If <strong><code>true</code></strong> the socket close call happens asynchronously. This parameter should be set to <strong><code>false</code></strong> for protocols like STOMP, that are commonly used in situations where a new connection is created for each read or write. Doing so ensures the socket close call happens synchronously. A synchronous close prevents the broker from running out of available sockets owing to the rapid cycling of connections.&#160;</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>connectionTimeout</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>30000</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If <strong><code>&gt;=1</code></strong> the value sets the connection timeout in milliseconds. A value of <strong><code>0</code></strong> denotes no timeout. Negative values are ignored.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>daemon</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If <strong><code>true</code></strong> the transport thread will run in daemon mode. Set this parameter to <strong><code>true</code></strong> when embedding the broker in a Spring container or a web container to allow the container to shut down correctly.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>diffServ</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>(Client only) The preferred Differentiated Services traffic class to be set on outgoing packets, as described in RFC 2475. Valid integer values: <strong><code>[0,64]</code></strong>. Valid string values: <strong><code>EF</code>, <code>AF[1-3][1-4]</code></strong> or <strong><code>CS[0-7]</code></strong>.</p><p>With JDK 6, only works when the JVM uses the IPv4 stack. To use the IPv4 stack set the system property <strong><code><a shape="rect" class="external-link" href="http://java.net" rel="nofollow">java.net</a>.preferIPv4Stack=true</code></strong>.</p><p><strong>Note</strong>: it's invalid to specify both <strong><code>diffServ</code></strong> and <strong><code>typeOfService</code></strong> at the same time as they share the same position in the TCP/IP packet headers.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>dynamicManagement</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If <strong><code>true</code></strong> the <strong><code>TransportLogger</code></strong> can be managed by JMX.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>ioBufferSize</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>8 * 1024</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Specifies the size of the buffer to be used between the TCP layer and the OpenWire layer where <strong><code>wireFormat</code></strong> based marshaling occurs.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>jmxPort</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>1099</code></p></td><td colspan="1" rowspan="1" class="confluenceTd" style="text-align: left;"><p>(Client Only)</p><p>Specifies the port that will be used by the JMX server to manage the <strong><code>TransportLoggers</code></strong>. This should only be set, via URI, by either a client producer or consumer as the broker creates its own JMX server.</p><p>Specifying an alternate JMX port is useful for developers that test a broker and client on the same machine and need to control both via JMX.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>keepAlive</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If <strong><code>true</code>, </strong>enables <a shape="rect" class="external-link" href="http://tldp.org/HOWTO/TCP-Keepalive-HOWTO/overview.html" rel="nofollow">TCP KeepAlive</a> on the broker connection to prevent connections from timing out at the TCP level.</p><p>This should <em>not</em> be confused with <strong><code>KeepAliveInfo</code></strong> messages as used by the <strong><code>InactivityMonitor</code>.</strong></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>logWriterName</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>default</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Sets the name of the <strong><code>org.apache.activemq.transport.LogWriter</code></strong> implementation to use.</p><p>Names are mapped to classes in the <strong><code>resources/META-INF/services/org/apache/activemq/transport/logwriters</code></strong> directory.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>maximumConnections</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Integer.MAX_VALUE</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The maximum number of sockets allowed for this broker.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>minmumWireFormatVersion</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The minimum remote <strong><code>wireFormat</code></strong> version that will be accepted (note the misspelling).</p><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><strong>Note</strong>: when the remote <strong><code>wireFormat</code></strong> version is lower than the configured minimum acceptable version an exception will be thrown and the connection attempt will be refused.</p></div></div><p>A value of <code><strong>0</strong></code> denotes no checking of the remote <strong><code>wireFormat</code></strong> version.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>socketBufferSize</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>64 * 1024</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Sets the size, in bytes, for the accepted socket's read and write buffers.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>soLinger</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>Integer.MIN_VALUE</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Sets the socket's option <strong><code>soLinger</code></strong> when the value is <strong><code>&gt; -1</code></strong>.</p><p>When set to <strong><code>-1</code></strong> the <strong><code>soLinger</code></strong> socket option is disabled.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>soTimeout</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Sets the socket's read timeout in milliseconds.</p><p>A value of <code><strong>0</strong></code> denotes no timeout.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>soWriteTimeout</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Sets the socket's write timeout in milliseconds. If the socket write operation does not complete before the specified timeout, the socket will be closed.</p><p>A value of <strong>0</strong> denotes no timeout.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>stackSize</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Set the stack size of the transport's background reading thread. Must be specified in multiples of <strong><code>128K</code></strong>.</p><p>A value of <code><strong>0</strong></code> indicates that this parameter is ignored.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>startLogging</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If <strong><code>true</code></strong> the <strong><code>TransportLogger</code></strong> object of the Transport stack&#160;will initially write messages to the log.</p><p>This parameter is ignored unless <strong><code>trace=true</code></strong>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>tcpNoDelay</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>If <strong><code>true</code></strong> the socket's option&#160;<strong><code>TCP_NODELAY</code></strong> is set. This disables Nagle's algorithm for small packet transmission.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>threadName</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>N/A</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>When this parameter is specified the name of the thread is modified during the invocation of a transport. The remote address is appended so that a call stuck in a transport method will have the destination information in the thread name. This is extremely useful when using thread dumps for degugging.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>trace</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Causes all commands that are sent over the transport to be logged.</p><p>To view the logged output define the <strong><code>Log4j</code></strong> logger: <strong><code>log4j.logger.org.apache.activemq.transport.TransportLogger=DEBUG</code></strong>.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>trafficClass</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The Traffic Class to be set on the socket.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>typeOfService</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>(Client only) The preferred Type of Service value to be set on outgoing packets. Valid integer values: <strong><code>[0,256]</code></strong>.</p><p>With JDK 6, only works when the JVM is configured to use the IPv4 stack. To use the IPv4 stack set the system property <strong><code><a shape="rect" class="external-link" href="http://java.net" rel="nofollow">java.net</a>.preferIPv4Stack=true</code></strong>.</p><p><strong>Note</strong>: it's invalid to specify both <strong><code>diffServ</code></strong> and <strong><code>typeOfService</code></strong> at the same time as they share the same position in the TCP/IP packet headers.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>useInactivityMonitor</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>When <strong><code>false</code></strong> the <code><strong>InactivityMonitor</strong></code> is disabled and connections will never time out.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>useKeepAlive</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>When <strong><code>true</code> <code> KeepAliveInfo</code></strong> messages are sent on an idle connection to prevent it from timing out.</p><p>If this parameter is <strong><code>false</code></strong> connections will still timeout if no data was received on the connection for the specified amount of time.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>useLocalHost</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>When <strong><code>true</code></strong> local connections will be made using the value <strong><code>localhost</code></strong> instead of the actual local host name.</p><p>On some operating systems, such as <strong><code>OS X</code></strong>, it's not possible to connect as the local host name so <strong><code>localhost</code></strong> is better.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>useQueueForAccept</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>When <strong><code>true</code></strong> accepted sockets are placed onto a queue for asynchronous processing using a separate thread.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>wireFormat</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>default</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>The name of the <strong><code>wireFormat</code></strong> factory to use.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>wireFormat.*</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>N/A</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Properties with this prefix are used to configure the <strong><code>wireFormat</code></strong>.</p><p>See <a shape="rect" href="configuring-wire-formats.html">Configuring Wire Formats</a> for more information.</p></td></tr></tbody></table></div><p>&#160;</p><h5 id="TCPTransportReference-DifferentiatedServicesorTypesofService">Differentiated Services or Types of Service</h5><p>There is support for setting Differentiated Services - as outlined in <a shape="rect" class="external-link" href="http://tools.ietf.org/html/rfc2475" rel="nofollow">IETF RCF 2475</a>. In order to configure the broker so that all outgoing packets from the broker match the DSCP values set on incoming packets - you will need to apply IP Tables scripts - found <a shape="rect" href="tcp-transport-reference.data/brokerConfig.tar.gz?version=1&amp;modificationDate=1273219000000&amp;api=v2" data-linked-resource-id="20873268" data-linked-resource-version="1" data-linked-resource-type="attachment" data-linked-resource-default-alias="brokerConfig.tar.gz" data-linked-resource-content-type="application/x-gzip" data-linked-resource-container-id="35993" data-linked-resource-container-version="57">here</a>.</p></div>