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.

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 asynchronous sending of persistent messages using one of the following options

  • set the useAsyncSend property on the ActiveMQConnectionFactory
  • set the property using the URI when you connect to the broker
tcp://localhost:61616?jms.useAsyncSend=true
© 2004-2011 The Apache Software Foundation.
Apache ActiveMQ, ActiveMQ, Apache, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners.
Graphic Design By Hiram