blob: 25b0f205af0739cdf92df033db3b737808f715ac [file] [log] [blame]
<div class="wiki-content maincontent"><h2 id="ConnectionConfigurationURI-ConnectionConfigurationURI">Connection Configuration URI</h2><p>An Apache ActiveMQ connection can be configured by explicitly setting properties on the <a shape="rect" class="external-link" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQConnection.html">ActiveMQConnection</a> or <a shape="rect" class="external-link" 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 id="ConnectionConfigurationURI-Example">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" class="external-link" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQConnectionFactory.html">ActiveMQConnectionFactory</a> to the following value to enable <a shape="rect" href="async-sends.xml">Async Sends</a></p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[tcp://localhost:61616?jms.useAsyncSend=true
]]></script>
</div></div><h3 id="ConnectionConfigurationURI-ConnectionOptions">Connection Options</h3><div class="confluence-information-macro confluence-information-macro-information"><p class="title">Use the 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 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></div></div><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>alwaysSessionAsync</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> 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" class="confluenceTd"><p><code>alwaysSyncSend</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&#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" class="confluenceTd"><p><code>auditDepth</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>2048</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p><code>auditMaximumProducerNumber</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>64</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Maximum number of producers that will be audited.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>checkForDuplicates</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&#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" class="confluenceTd"><p><code>clientID</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>null</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Sets the JMS clientID to use for the connection.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>closeTimeout</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>15000</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p><code>consumerExpiryCheckEnabled</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p><code>copyMessageOnSend</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p><code>disableTimeStampsByDefault</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p><code>dispatchAsync</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Should the broker <a shape="rect" href="consumer-dispatch-async.xml">dispatch messages asynchronously</a> to the consumer?</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>nestedMapAndListEnabled</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>true</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Controls whether <a shape="rect" href="structured-message-properties-and-mapmessages.xml">Structured Message Properties and MapMessages</a> 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" class="confluenceTd"><p><code>objectMessageSerializationDefered</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 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" class="confluenceTd"><p><code>optimizeAcknowledge</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p><code>optimizeAcknowledgeTimeOut</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>300</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p><code>optimizedAckScheduledAckInterval</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>0</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p><code>optimizedMessageDispatch</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&#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" class="confluenceTd"><p><code>useAsyncSend</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Forces the use of <a shape="rect" href="async-sends.xml">Async Sends</a> 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" class="confluenceTd"><p><code>useCompression</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p>Enables the use of compression on the message's body.</p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>useRetroactiveConsumer</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>false</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="confluenceTd"><p><code>warnAboutUnstartedConnectionTimeout</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><code>500</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><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" class="external-link" href="http://java.sun.com/j2ee/1.4/docs/api/javax/jms/Connection.html#start()" rel="nofollow">Connection.start()</a> and a message is received by a consumer. It is a very common gotcha to forget to <a shape="rect" href="i-am-not-receiving-any-messages-what-is-wrong.xml">start the connection and then wonder why no messages are delivered</a> 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></div><h3 id="ConnectionConfigurationURI-NestedOptions">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><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>Object configured</p></th><th colspan="1" rowspan="1" class="confluenceTh"><p>See Also</p></th></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>jms.blobTransferPolicy.*</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" class="external-link" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/blob/BlobTransferPolicy.html">BlobTransferPolicy</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" class="unresolved" href="#">Blob Message</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>jms.prefetchPolicy.*</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" class="external-link" href="http://http//activemq.apache.org/maven/apidocs/org/apache/activemq/ActiveMQPrefetchPolicy.html" rel="nofollow">ActiveMQPrefetchPolicy</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="what-is-the-prefetch-limit-for.xml">What is the Prefetch Limit For?</a></p></td></tr><tr><td colspan="1" rowspan="1" class="confluenceTd"><p><code>jms.redeliveryPolicy.*</code></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" class="external-link" href="http://activemq.apache.org/maven/apidocs/org/apache/activemq/RedeliveryPolicy.html">RedeliveryPolicy</a></p></td><td colspan="1" rowspan="1" class="confluenceTd"><p><a shape="rect" href="redelivery-policy.xml">Redelivery Policy</a></p></td></tr></tbody></table></div><p>For example you could set</p><div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl">
<script class="brush: java; gutter: false; theme: Default" type="syntaxhighlighter"><![CDATA[tcp://localhost:61616?jms.prefetchPolicy.all=100&amp;jms.redeliveryPolicy.maximumRedeliveries=5
]]></script>
</div></div></div>