blob: 5acf22e33ecb005338ef96a9b072f65f0e820c15 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Asciidoctor 2.0.18">
<link rel="icon" type="image/png" href="images/favicon.png">
<title>Data Retention</title>
<link rel="stylesheet" href="css/asciidoctor.css">
<link rel="stylesheet" href="css/font-awesome.css">
<link rel="stylesheet" href="css/rouge-github.css">
</head>
<body class="book toc2 toc-left">
<div id="header">
<h1>Data Retention</h1>
<div id="toc" class="toc2">
<div id="toctitle"><a href="index.html">User Manual for 2.33.0</a></div>
<ul class="sectlevel3">
<li><a href="#paging-and-large-messages">1. Paging and Large Messages</a></li>
<li><a href="#non-persistent-messages">2. Non Persistent Messages</a></li>
<li><a href="#recovering-data-from-retention">1. Recovering data from retention</a>
<ul class="sectlevel2">
<li><a href="#cli-recover-operation">1.1. CLI recover operation</a></li>
</ul>
</li>
</ul>
</div>
</div>
<div id="content">
<div id="preamble">
<div class="sectionbody">
<div class="paragraph">
<p>If you enable <code>journal-retention</code> on broker.xml, ActiveMQ Artemis will keep copy of every data that has passed through the broker on this folder.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="xml"> ...
<span class="nt">&lt;journal-retention</span> <span class="na">unit=</span><span class="s">"DAYS"</span> <span class="na">directory=</span><span class="s">"history"</span> <span class="na">period=</span><span class="s">"365"</span> <span class="na">storage-limit=</span><span class="s">"10G"</span><span class="nt">/&gt;</span>
...</code></pre>
</div>
</div>
<div class="paragraph">
<p>ActiveMQ Artemis will keep a copy of each generated journal file, up to the configured retention period, at the unit chose.
On the example above the system would keep all the journal files up to 365 days.</p>
</div>
<div class="paragraph">
<p>It is also possible to limit the number of files kept on the retention directory.
You can keep a storage-limit, and the system will start removing older files when you have more files than the configured storage limit.</p>
</div>
<div class="paragraph">
<p>Notice the storage limit is optional however you need to be careful to not run out of disk space at the retention folder or the broker might be shutdown because of a critical IO failure.</p>
</div>
<div class="paragraph">
<p>You can use the CLI tools to inspect and recover data from the history, by just passing the journal folder being the retention directory.</p>
</div>
<div class="paragraph">
<p>Example:</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="shell">./artemis data print <span class="nt">--journal</span> ../data/history</code></pre>
</div>
</div>
</div>
</div>
<div class="sect3">
<h4 id="paging-and-large-messages"><a class="anchor" href="#paging-and-large-messages"></a><a class="link" href="#paging-and-large-messages">1. Paging and Large Messages</a></h4>
<div class="paragraph">
<p>When retention is enabled, paging and large messages are also stored on the retention folder for replaying, so replay will also work for both paged and large messages.</p>
</div>
</div>
<div class="sect3">
<h4 id="non-persistent-messages"><a class="anchor" href="#non-persistent-messages"></a><a class="link" href="#non-persistent-messages">2. Non Persistent Messages</a></h4>
<div class="paragraph">
<p>Non persistent messages are never stored anywhere in the broker. If you intend to retain data your producers should be using Durable messages.</p>
</div>
</div>
<div class="sect1">
<h2 id="recovering-data-from-retention"><a class="anchor" href="#recovering-data-from-retention"></a><a class="link" href="#recovering-data-from-retention">1. Recovering data from retention</a></h2>
<div class="sectionbody">
<div class="paragraph">
<p>To recover data from the retention folder, you can use the method <a href="https://activemq.apache.org/components/artemis/documentation/javadocs/javadoc-latest/org/apache/activemq/artemis/api/core/management/ActiveMQServerControl.html#replay(java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String)">replay</a> on the management console:</p>
</div>
<div class="imageblock text-center">
<div class="content">
<img src="images/replay-method.png" alt="replay method">
</div>
</div>
<div class="paragraph">
<p>The broker will scan the set of files accordingly to the parameters you passed and it will send these methods to a target queue that you selected.</p>
</div>
<div class="sect2">
<h3 id="cli-recover-operation"><a class="anchor" href="#cli-recover-operation"></a><a class="link" href="#cli-recover-operation">1.1. CLI recover operation</a></h3>
<div class="paragraph">
<p>The CLI recover operation is intended as a low level operation, where data is read and recovered directly into a set of journal files.
Notice uou should never manipulate journal files that are being used by an active broker as that could risk the integrity of your data files and running broker.</p>
</div>
<div class="listingblock">
<div class="content">
<pre class="rouge highlight nowrap"><code data-lang="shell">./artemis data recovery <span class="nt">--journal</span> ../data/history <span class="nt">--target</span> ../data/recovered <span class="nt">--large-messages</span> ../data/large-messages</code></pre>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>