blob: bfc3d9395a95e017d2d77937ca33a3431aa719be [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>ActiveMQ</title>
<link rel="icon" type="image/png" href="/assets/img/favicon.png">
<link rel="stylesheet" href="/css/main.css">
<script defer src="/js/fontawesome-all.min.js" integrity="sha384-rOA1PnstxnOBLzCLMcre8ybwbTmemjzdNlILg8O7z1lUkLXozs4DHonlDtnE7fpc"></script>
<script src="/js/jquery.slim.min.js" integrity="sha384-5AkRS45j4ukf+JbWAfHL8P4onPA9p0KwwP7pUdjSQA3ss9edbJUJc/XcYAiheSSz"></script>
<script src="/js/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"></script>
<script src="/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light fixed-top">
<div class="container">
<!-- <a class="navbar-brand mr-auto" href="#"><img style="height: 50px" src="assets/img/apache-feather.png" /></a> -->
<a class="navbar-brand mr-auto" href="/"><img src="/assets/img/activemq_logo_black_small.png" style="height: 50px"/></a>
<button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbarContent" aria-controls="navbarContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="ml-auto collapse navbar-collapse" id="navbarContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link active" href="/news">News</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownComponents" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Components<span class="caret"></span></a>
<ul class="dropdown-menu dropdown-menu-center" aria-labelledby="navbarDropdownComponents">
<div class="row">
<div class="col-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="/components/classic">ActiveMQ Classic</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/artemis/">ActiveMQ Artemis</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/nms">NMS Clients</a></li>
<li class="nav-item"><a class="dropdown-item" href="/components/cms">CMS Client</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownCommunity" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Community<span class="caret"></span></a>
<ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownCommunity">
<div class="row">
<div class="col-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="/contact">Contact Us</a></li>
<li class="nav-item"><a class="dropdown-item" href="/contributing">Contribute</a></li>
<li class="nav-item"><a class="dropdown-item" href="/issues">Report Issues</a></li>
<li class="nav-item"><a class="dropdown-item" href="/support">Get Support</a></li>
</ul>
</div>
</div>
</ul>
</li>
<li class="nav-item dropdown">
<a class="nav-link" id="navbarDropdownTeam" data-target="#" href="" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><img src="/assets/img/feather.png" style="height:20px">Apache<span class="caret"></span></a>
<ul class="dropdown-menu dropdown-menu-center multi-column columns-1" aria-labelledby="navbarDropdownTeam">
<div class="row">
<div class="col-sm-12">
<ul class="multi-column-dropdown">
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org">The Apache Software Foundation</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/licenses/">License</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/foundation/thanks.html">Thanks</a></li>
<li class="nav-item"><a class="dropdown-item" href="/security-advisories">Security</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://www.apache.org/events/current-event">Events</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://people.apache.org/phonebook.html?pmc=activemq">PMC & Committers</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://whimsy.apache.org/board/minutes/ActiveMQ.html">Board Reports</a></li>
<li class="nav-item"><a class="dropdown-item" href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy Policy</a></li>
</ul>
</div>
</div>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="content">
<div class="page-title-classic">
<div class="container">
<h1>AMQ Message Store</h1>
</div>
</div>
<div class="container" >
<div class="row" style="margin-top: 30px">
<div class="col-12 classic">
<p><a href="features">Features</a> &gt; <a href="persistence">Persistence</a> &gt; <a href="amq-message-store">AMQ Message Store</a></p>
<h2 id="the-basics">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 />
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>
<p><img src="assets/img/amqstore.png" alt="" /></p>
<p>References to messages are held in memory, and periodically inserted into the reference store to improve performance.</p>
<p>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>
<h2 id="configuration">Configuration</h2>
<p>By default ActiveMQ Classic 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>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code> &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;
</code></pre></div></div>
<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 id="amq-store-properties">AMQ Store Properties</h3>
<table>
<thead>
<tr>
<th>property name</th>
<th>default value</th>
<th>Comments</th>
</tr>
</thead>
<tbody>
<tr>
<td><code class="language-plaintext highlighter-rouge">directory</code></td>
<td>activemq-data</td>
<td>the path to the directory to use to store the message store data and log files</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">useNIO</code></td>
<td>true</td>
<td>use NIO to write messages to the data logs</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">syncOnWrite</code></td>
<td>false</td>
<td>sync every write to disk</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">maxFileLength</code></td>
<td>32mb</td>
<td>a hint to set the maximum size of the message data logs</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">persistentIndex</code></td>
<td>true</td>
<td>use a persistent index for the message logs. If this is false, an in-memory structure is maintained</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">maxCheckpointMessageAddSize</code></td>
<td>4kb</td>
<td>the maximum number of messages to keep in a transaction before automatically committing</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">cleanupInterval</code></td>
<td>30000</td>
<td>time (ms) before checking for a discarding/moving message data logs that are no longer used</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">indexBinSize</code></td>
<td>1024</td>
<td>default number of bins used by the index. The bigger the bin size - the better the relative performance of the index</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">indexKeySize</code></td>
<td>96</td>
<td>the size of the index key - the key is the message id</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">indexPageSize</code></td>
<td>16kb</td>
<td>the size of the index page - the bigger the page - the better the write performance of the index</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">directoryArchive</code></td>
<td>archive</td>
<td>the path to the directory to use to store discarded data logs</td>
</tr>
<tr>
<td><code class="language-plaintext highlighter-rouge">archiveDataLogs</code></td>
<td>false</td>
<td>if true data logs are moved to the archive directory instead of being deleted</td>
</tr>
</tbody>
</table>
<h2 id="data-structure">Data Structure</h2>
<p>In the data directory defined for the AMQ Store there is the following directory structure:</p>
<p><img src="assets/img/amqdir.png" alt="" /></p>
<h3 id="top-level">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 />
Below this top level directory are the following sub directories:</p>
<h3 id="archive">archive</h3>
<p>message data logs are moved here when they are discarded.<br />
n.b. this directory only exists when the property archiveDataLogs is enabled</p>
<h3 id="journal">journal</h3>
<p>Used to hold the message data logs</p>
<h3 id="kr-store">kr-store</h3>
<p>The directory structure of the Kaha reference store (if used)</p>
<h5 id="data">data</h5>
<p>The indexes used to reference the message data logs in the journal for fast retrieval</p>
<h5 id="state">state</h5>
<p>The state of the store - i.e. names of durable subscribers - the reason for this is described in <a href="#recovery">Recovery</a></p>
<h3 id="tmp-storage">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>
<h2 id="recovery-">Recovery <a name="#recovery"></a></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>
</div>
</div>
</div>
<div class="row sitemap">
<div class="col-sm-12">
<div class="container">
<div class="row">
<div class="col-sm-12">
<div class="row">
<div class="col-sm-3">
<div >
<img class="float-left" style="max-height: 100px" src="/assets/img/activemq_logo_white_vertical_small.png"/>
</div>
</div>
<div style="text-align: center; margin-bottom: 0px; margin-top: 30px; font-size: 65%" class="col-sm-6">
<p><a href="https://www.apache.org/foundation/marks/list/">Apache, ActiveMQ, Apache ActiveMQ</a>, the Apache feather logo, and the Apache ActiveMQ project logo are trademarks of The Apache Software Foundation. Copyright &copy; 2024, The Apache Software Foundation. Licensed under <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License 2.0</a>.</p>
</div>
<div class="col-sm-3">
<div >
<a href="https://www.apache.org"><img class="float-right" style="margin-top: 10px; max-height: 80px" src="/assets/img/apache-logo-small.png"/></a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>