| <div class="wiki-content maincontent"> |
| <p>The default setting for ActiveMQ is that all persistent messages outside of a transaction are sent to a broker are synchronous. This means that the send method is blocked until the message is received by the broker, its then written to disk - then a response is returned to the client and the send() unblocks with success or throws a JMSException if the send could not complete (e.g. due to a security exception).  In the case of the persistent messages being sent in a transaction, only the commit is synchronous since if the commit succeeds, then it means that all of the sends and acknowledgements in the transaction succeeded.</p> |
| |
| <p>For performance reasons you may wish to stream messages to the broker as fast as possible even if you are using persistent messages. So you can enable <strong>asynchronous sending</strong> of persistent messages using one of the following options</p> |
| <ul><li>set the useAsyncSend property on the ActiveMQConnectionFactory</li><li>set the property using the URI when you connect to the broker</li></ul> |
| |
| |
| <div class="code panel pdl" style="border-width: 1px;"><div class="codeContent panelContent pdl"> |
| <pre class="brush: java; gutter: false; theme: Default" style="font-size:12px;"> |
| tcp://localhost:61616?jms.useAsyncSend=true |
| </pre> |
| </div></div></div> |
| |