blob: a9e7bedf15bbdccfac7115658719a98ffa6716d7 [file] [log] [blame]
<div class="wiki-content maincontent"><h2>The Basics</h2>
<p>This is the default storage for AcitveMQ 5 and above. The AMQ Message Store is an embeddable transactional message storage solution that is extremely fast and reliable.<br clear="none">
message commands are written to a transactional journal - which consists of rolling data logs - which means writing is extremely fast and the state of the store is easily recoverable.</p>
<p>Messages themselves are persisted in the data logs of the journal - with references to their location being held by a reference store (by default Kaha) for fast retrevial.</p>
<structured-macro ac:macro-id="7b4e09fb-98ad-415f-948f-997829c0c1e0" ac:name="section" ac:schema-version="1"><rich-text-body>
<structured-macro ac:macro-id="0723c06c-d5db-4d8f-abc1-61861fe50ad6" ac:name="column" ac:schema-version="1"><parameter ac:name="width">50%</parameter><rich-text-body>
<p><image ac:align="left"><attachment ri:filename="amqstore.png"></attachment></image></p></rich-text-body></structured-macro>
<structured-macro ac:macro-id="84ca978d-31f3-486b-a66f-851f790e124e" ac:name="column" ac:schema-version="1"><parameter ac:name="width">50%</parameter><rich-text-body>
<p><br clear="none" class="atl-forced-newline">
<br clear="none" class="atl-forced-newline">
<br clear="none" class="atl-forced-newline">
References to messages are held in memory, and periodically inserted into the reference store to improve performance.
<br clear="none" class="atl-forced-newline">
<br clear="none" class="atl-forced-newline">
The messages are stored in data logs, which are individual files, typically 32mb in size (though this is configurable, they can be larger if the size of a message is large than the file size). When all the messages in a data log have been successfully consumed, the data log file is marked as being ready to be deleted - or archived - which will happen at the next clean up period.</p></rich-text-body></structured-macro>
</rich-text-body></structured-macro>
<h2>Configuration</h2>
<p>By default ActiveMQ will use the the AMQ Store - and its default settings. You can configure the properties of the AMQ Store however, by explictly defining its persistence adapter (amqPersistenceAdapter):</p>
<structured-macro ac:macro-id="2c5bea15-0e72-4a54-87da-44e58c3c6f55" ac:name="code" ac:schema-version="1"><plain-text-body>
&lt;broker brokerName="broker" persistent="true" useShutdownHook="false"&gt;
&lt;persistenceAdapter&gt;
&lt;amqPersistenceAdapter directory="${activemq.base}/activemq-data" maxFileLength="32mb"/&gt;
&lt;/persistenceAdapter&gt;
&lt;transportConnectors&gt;
&lt;transportConnector uri="tcp://localhost:61616"/&gt;
&lt;/transportConnectors&gt;
&lt;/broker&gt;
</plain-text-body></structured-macro>
<p>The above shows the configuration required to set the AMQ Store through its amqPersistenceAdapter - and explicity setting the directory and maxFileLength properties.</p>
<h3>AMQ Store Properties</h3>
<table><tbody><tr><th colspan="1" rowspan="1"><p>property name</p></th><th colspan="1" rowspan="1"><p>default value</p></th><th colspan="1" rowspan="1"><p>Comments</p></th></tr><tr><td colspan="1" rowspan="1"><p>directory</p></td><td colspan="1" rowspan="1"><p>activemq-data</p></td><td colspan="1" rowspan="1"><p>the path to the directory to use to store the message store data and log files</p></td></tr><tr><td colspan="1" rowspan="1"><p>useNIO</p></td><td colspan="1" rowspan="1"><p>true</p></td><td colspan="1" rowspan="1"><p>use NIO to write messages to the data logs</p></td></tr><tr><td colspan="1" rowspan="1"><p>syncOnWrite</p></td><td colspan="1" rowspan="1"><p>false</p></td><td colspan="1" rowspan="1"><p>sync every write to disk</p></td></tr><tr><td colspan="1" rowspan="1"><p>maxFileLength</p></td><td colspan="1" rowspan="1"><p>32mb</p></td><td colspan="1" rowspan="1"><p>a hint to set the maximum size of the message data logs</p></td></tr><tr><td colspan="1" rowspan="1"><p>persistentIndex</p></td><td colspan="1" rowspan="1"><p>true</p></td><td colspan="1" rowspan="1"><p>use a persistent index for the message logs. If this is false, an in-memory structure is maintained</p></td></tr><tr><td colspan="1" rowspan="1"><p>maxCheckpointMessageAddSize</p></td><td colspan="1" rowspan="1"><p>4kb</p></td><td colspan="1" rowspan="1"><p>the maximum number of messages to keep in a transaction before automatically committing</p></td></tr><tr><td colspan="1" rowspan="1"><p>cleanupInterval</p></td><td colspan="1" rowspan="1"><p>30000</p></td><td colspan="1" rowspan="1"><p>time (ms) before checking for a discarding/moving message data logs that are no longer used</p></td></tr><tr><td colspan="1" rowspan="1"><p>indexBinSize</p></td><td colspan="1" rowspan="1"><p>1024</p></td><td colspan="1" rowspan="1"><p>default number of bins used by the index. The bigger the bin size - the better the relative performance of the index</p></td></tr><tr><td colspan="1" rowspan="1"><p>indexKeySize</p></td><td colspan="1" rowspan="1"><p>96</p></td><td colspan="1" rowspan="1"><p>the size of the index key - the key is the message id </p></td></tr><tr><td colspan="1" rowspan="1"><p>indexPageSize</p></td><td colspan="1" rowspan="1"><p>16kb</p></td><td colspan="1" rowspan="1"><p>the size of the index page - the bigger the page - the better the write performance of the index </p></td></tr><tr><td colspan="1" rowspan="1"><p>directoryArchive</p></td><td colspan="1" rowspan="1"><p>archive</p></td><td colspan="1" rowspan="1"><p>the path to the directory to use to store discarded data logs</p></td></tr><tr><td colspan="1" rowspan="1"><p>archiveDataLogs</p></td><td colspan="1" rowspan="1"><p>false</p></td><td colspan="1" rowspan="1"><p>if true data logs are moved to the archive directory instead of being deleted</p></td></tr></tbody></table>
<h2>Data Structure</h2>
<p>In the data directory defined for the AMQ Store there is the following directory structure:</p>
<structured-macro ac:macro-id="7a6c812e-6ce6-4a10-a407-abe98d623408" ac:name="section" ac:schema-version="1"><rich-text-body>
<structured-macro ac:macro-id="acd7fd4d-13a5-4cdb-a62e-0d91765ed0d6" ac:name="column" ac:schema-version="1"><parameter ac:name="width">50%</parameter><rich-text-body>
<p><image ac:align="left"><attachment ri:filename="amqdir.png"></attachment></image></p></rich-text-body></structured-macro>
<structured-macro ac:macro-id="51bcef4f-c3cf-41ad-b525-016965a64462" ac:name="column" ac:schema-version="1"><parameter ac:name="width">50%</parameter><rich-text-body>
<h3>Top level</h3>
<p>the message broker's name is used to distinguish its directory of message data. By default, the broker name is local host.<br clear="none">
Below this top level directory are the following sub directories:</p>
<h3>archive</h3>
<p>message data logs are moved here when they are discarded.<br clear="none">
n.b. this directory only exists when the property archiveDataLogs is enabled</p>
<h3>journal</h3>
<p>Used to hold the message data logs</p>
<h3>kr-store</h3>
<p>The directory structure of the Kaha reference store (if used)</p>
<h5>data</h5>
<p>The indexes used to reference the message data logs in the journal for fast retrieval</p>
<h5>state</h5>
<p>The state of the store - i.e. names of durable subscribers - the reason for this is described in <link ac:anchor="Recovery"><link-body>Recovery</link-body></link></p>
<h3>tmp-storage</h3>
<p>use to hold data files for transient messages that may be stored on disk to alleviate memory consumption - e.g. non-persistent topic messages awaiting delivery to an active, but slow subscriber.</p></rich-text-body></structured-macro></rich-text-body></structured-macro>
<h2>Recovery</h2>
<p>If the message broker does not shutdown properly, then the reference store indexes are cleaned and the message data files (which contain messages/acknowledgements and transactional boundaries) are replayed to rebuild up the message store state. It is possbile to force automatic recovery if using the Kaha reference store (the default) by deleting the kr-store/state/ directory.</p></div>