blob: 66488273268b575f8745e6f412c78890b958ad46 [file] [log] [blame]
<div class="wiki-content maincontent"><h2>Connection Configuration URI</h2><p>An Apache ActiveMQ connection can be configured by explicitly setting properties on the <a shape="rect" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQConnection.html">ActiveMQConnection</a> or <a shape="rect" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQConnectionFactory.html">ActiveMQConnectionFactory</a> objects themselves via the bean properties or using the following URI syntax.</p><h3>Example</h3><p>You set the property called&#160;<strong><code>jms.$PROPERTY</code></strong> on a regular connection URI. For example you can set the&#160;<strong><code>brokerURL</code></strong> on your <a shape="rect" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQConnectionFactory.html">ActiveMQConnectionFactory</a> to the following value to enable <link><page ri:content-title="Async Sends"></page></link></p><structured-macro ac:macro-id="cdb20bb5-233a-4d06-a1d6-95b6a9d4082e" ac:name="code" ac:schema-version="1"><plain-text-body>tcp://localhost:61616?jms.useAsyncSend=true
</plain-text-body></structured-macro><h3>Connection Options</h3><structured-macro ac:macro-id="677dbbcf-a4ab-498d-b67a-2360c5dec022" ac:name="info" ac:schema-version="1"><parameter ac:name="title">Use the Correct Prefix!</parameter><rich-text-body><p>The following options should be prefixed with&#160;<strong><code>jms.</code></strong> when used on a&#160;<strong><code>brokerURL</code></strong> or a broker's transport connector.</p></rich-text-body></structured-macro><table><tbody><tr><th colspan="1" rowspan="1"><p>Option Name</p></th><th colspan="1" rowspan="1"><p>Default Value</p></th><th colspan="1" rowspan="1"><p>Description</p></th></tr><tr><td colspan="1" rowspan="1"><p><code>alwaysSessionAsync</code></p></td><td colspan="1" rowspan="1"><p><code>true</code></p></td><td colspan="1" rowspan="1"><p>When <strong><code>true</code></strong> a separate thread is used for dispatching messages for each Session in the Connection.</p><p>A separate thread is always used when there's more than one session, or the session isn't in <strong><code>Session.AUTO_ACKNOWLEDGE</code></strong> or <strong><code>Session.DUPS_OK_ACKNOWLEDGE</code></strong> mode.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>alwaysSyncSend</code></p></td><td colspan="1" rowspan="1"><p><code>false</code></p></td><td colspan="1" rowspan="1"><p>When&#160;<strong><code>true</code></strong> a&#160;<strong><code>MessageProducer</code></strong> will always use Sync sends when sending a Message even if it is not required for the Delivery Mode.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>auditDepth</code></p></td><td colspan="1" rowspan="1"><p><code>2048</code></p></td><td colspan="1" rowspan="1"><p>The size of the message window that will be audited for duplicates and out of order messages.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>auditMaximumProducerNumber</code></p></td><td colspan="1" rowspan="1"><p><code>64</code></p></td><td colspan="1" rowspan="1"><p>Maximum number of producers that will be audited.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>checkForDuplicates</code></p></td><td colspan="1" rowspan="1"><p><code>true</code></p></td><td colspan="1" rowspan="1"><p>When&#160;<strong><code>true</code></strong> the consumer will check for duplicate messages and properly handle the message to make sure that it is not processed twice inadvertently.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>clientID</code></p></td><td colspan="1" rowspan="1"><p><code>null</code></p></td><td colspan="1" rowspan="1"><p>Sets the JMS clientID to use for the connection.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>closeTimeout</code></p></td><td colspan="1" rowspan="1"><p><code>15000</code></p></td><td colspan="1" rowspan="1"><p>Sets the timeout, in milliseconds, before a close is considered complete. Normally a&#160;<strong><code>close()</code></strong> on a connection waits for confirmation from the broker.</p><p>This allows the close operation to timeout preventing the client from hanging when no broker is available.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>consumerExpiryCheckEnabled</code></p></td><td colspan="1" rowspan="1"><p><code>true</code></p></td><td colspan="1" rowspan="1"><p>Controls whether message expiration checking is done in each&#160;<strong><code>MessageConsumer</code></strong> prior to dispatching a message. Disabling this check can lead to consumption of expired messages. (since 5.11).</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>copyMessageOnSend</code></p></td><td colspan="1" rowspan="1"><p><code>true</code></p></td><td colspan="1" rowspan="1"><p>Should a JMS message be copied to a new JMS Message object as part of the&#160;<strong><code>send()</code></strong> method in JMS. This is enabled by default to be compliant with the JMS specification.</p><p>For a performance boost set to&#160;<strong><code>false</code></strong> if you do not mutate JMS messages after they are sent.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>disableTimeStampsByDefault</code></p></td><td colspan="1" rowspan="1"><p><code>false</code></p></td><td colspan="1" rowspan="1"><p>Sets whether or not timestamps on messages should be disabled or not.</p><p>For a small performance boost set to <strong><code>false</code></strong>.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>dispatchAsync</code></p></td><td colspan="1" rowspan="1"><p><code>false</code></p></td><td colspan="1" rowspan="1"><p>Should the broker <link><page ri:content-title="Consumer Dispatch Async"></page><plain-text-link-body>dispatch messages asynchronously</plain-text-link-body></link> to the consumer?</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>nestedMapAndListEnabled</code></p></td><td colspan="1" rowspan="1"><p><code>true</code></p></td><td colspan="1" rowspan="1"><p>Controls whether <link><page ri:content-title="Structured Message Properties and MapMessages"></page></link> are supported so that Message properties and&#160;<strong><code>MapMessage</code></strong> entries can contain nested Map and List objects. Available from version 4.1.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>objectMessageSerializationDefered</code></p></td><td colspan="1" rowspan="1"><p><code>false</code></p></td><td colspan="1" rowspan="1"><p>When an object is set on an <strong><code>ObjectMessage</code></strong> the JMS spec requires the object be serialized by that set method.</p><p>When&#160;<strong><code>true</code></strong> the object will not be serialized. The object may subsequently be serialized if the message needs to be sent over a socket or stored to disk.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>optimizeAcknowledge</code></p></td><td colspan="1" rowspan="1"><p><code>false</code></p></td><td colspan="1" rowspan="1"><p>Enables an optimized acknowledgement mode where messages are acknowledged in batches rather than individually. Alternatively, you could use&#160;<strong><code>Session.DUPS_OK_ACKNOWLEDGE</code></strong> acknowledgement mode for the consumers which can often be faster.</p><p><strong>WARNING</strong>: enabling this issue could cause some issues with auto-acknowledgement on reconnection.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>optimizeAcknowledgeTimeOut</code></p></td><td colspan="1" rowspan="1"><p><code>300</code></p></td><td colspan="1" rowspan="1"><p>If &gt; 0, specifies the max time, in milliseconds, between batch acknowledgements when&#160;<strong><code>optimizeAcknowledge</code></strong> is enabled. (since 5.6).</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>optimizedAckScheduledAckInterval</code></p></td><td colspan="1" rowspan="1"><p><code>0</code></p></td><td colspan="1" rowspan="1"><p>If &gt; 0, specifies a <span style="line-height: 1.4285715;">time interval upon which all the outstanding ACKs are delivered when optimized acknowledge is used so that a long running consumer that doesn't receive any more messages will eventually ACK the last few un-ACK'ed messages (since 5.7).</span></p></td></tr><tr><td colspan="1" rowspan="1"><p><code>optimizedMessageDispatch</code></p></td><td colspan="1" rowspan="1"><p><code>true</code></p></td><td colspan="1" rowspan="1"><p>If&#160;<strong><code>true</code></strong> a larger prefetch limit is used - only applicable for durable topic subscribers.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>useAsyncSend</code></p></td><td colspan="1" rowspan="1"><p><code>false</code></p></td><td colspan="1" rowspan="1"><p>Forces the use of <link><page ri:content-title="Async Sends"></page></link> which adds a massive performance boost; but means that the&#160;<strong><code>send()</code></strong> method will return immediately whether the message has been sent or not which could lead to message loss.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>useCompression</code></p></td><td colspan="1" rowspan="1"><p><code>false</code></p></td><td colspan="1" rowspan="1"><p>Enables the use of compression on the message's body.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>useRetroactiveConsumer</code></p></td><td colspan="1" rowspan="1"><p><code>false</code></p></td><td colspan="1" rowspan="1"><p>Sets whether or not retroactive consumers are enabled. Retroactive consumers allow non-durable topic subscribers to receive old messages that were published before the non-durable subscriber started.</p></td></tr><tr><td colspan="1" rowspan="1"><p><code>warnAboutUnstartedConnectionTimeout</code></p></td><td colspan="1" rowspan="1"><p><code>500</code></p></td><td colspan="1" rowspan="1"><p>The timeout, in milliseconds, from the time of connection creation to when a warning is generated if the connection is not properly started via <a shape="rect" href="http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Connection.html#start()">Connection.start()</a> and a message is received by a consumer. It is a very common gotcha to forget to <link><page ri:content-title="I am not receiving any messages, what is wrong"></page><plain-text-link-body>start the connection and then wonder why no messages are delivered</plain-text-link-body></link> so this option makes the default case to create a warning if the user forgets.</p><p>To disable the warning just set the value to <strong><code>&lt; 0</code></strong>.</p></td></tr></tbody></table><h3>Nested Options</h3><p>You can also configure nested objects on the connection object using the given prefixes. See the javadoc for a breakdown of each individual property.</p><table><tbody><tr><th colspan="1" rowspan="1"><p>Option Name</p></th><th colspan="1" rowspan="1"><p>Object configured</p></th><th colspan="1" rowspan="1"><p>See Also</p></th></tr><tr><td colspan="1" rowspan="1"><p><code>jms.blobTransferPolicy.*</code></p></td><td colspan="1" rowspan="1"><p><a shape="rect" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/blob/BlobTransferPolicy.html">BlobTransferPolicy</a></p></td><td colspan="1" rowspan="1"><p><link><page ri:content-title="Blob Message"></page><plain-text-link-body>Blob Message</plain-text-link-body></link></p></td></tr><tr><td colspan="1" rowspan="1"><p><code>jms.prefetchPolicy.*</code></p></td><td colspan="1" rowspan="1"><p><a shape="rect" href="http://http//activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQPrefetchPolicy.html">ActiveMQPrefetchPolicy</a></p></td><td colspan="1" rowspan="1"><p><link><page ri:content-title="What is the Prefetch Limit For?"></page></link></p></td></tr><tr><td colspan="1" rowspan="1"><p><code>jms.redeliveryPolicy.*</code></p></td><td colspan="1" rowspan="1"><p><a shape="rect" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/RedeliveryPolicy.html">RedeliveryPolicy</a></p></td><td colspan="1" rowspan="1"><p><link><page ri:content-title="Redelivery Policy"></page></link></p></td></tr></tbody></table><p>For example you could set</p><structured-macro ac:macro-id="0255c160-beb2-4274-9d9c-5c9fcf102482" ac:name="code" ac:schema-version="1"><plain-text-body>tcp://localhost:61616?jms.prefetchPolicy.all=100&amp;jms.redeliveryPolicy.maximumRedeliveries=5
</plain-text-body></structured-macro></div>