blob: fdc6438a09d04dccc2f2fe2d3c9d9712be7e86f3 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Message retention and expiry · Apache Pulsar</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta name="generator" content="Docusaurus"/><meta name="description" content="Pulsar brokers are responsible for handling messages that pass through Pulsar, including [persistent storage](/docs/en/concepts-architecture-overview#persistent-storage) of messages. By default, for each topic, brokers only retain messages that are in at least one backlog. A backlog is the set of unacknowledged messages for a particular subscription. As a topic can have multiple subscriptions, a topic can have multiple backlogs."/><meta name="docsearch:version" content="2.10.0"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="Message retention and expiry · Apache Pulsar"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pulsar.apache.org/"/><meta property="og:description" content="Pulsar brokers are responsible for handling messages that pass through Pulsar, including [persistent storage](/docs/en/concepts-architecture-overview#persistent-storage) of messages. By default, for each topic, brokers only retain messages that are in at least one backlog. A backlog is the set of unacknowledged messages for a particular subscription. As a topic can have multiple subscriptions, a topic can have multiple backlogs."/><meta name="twitter:card" content="summary"/><meta name="twitter:image" content="https://pulsar.apache.org/img/pulsar.svg"/><link rel="shortcut icon" href="/img/pulsar.ico"/><link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css"/><link rel="alternate" type="application/atom+xml" href="https://pulsar.apache.org/blog/atom.xml" title="Apache Pulsar Blog ATOM Feed"/><link rel="alternate" type="application/rss+xml" href="https://pulsar.apache.org/blog/feed.xml" title="Apache Pulsar Blog RSS Feed"/><link rel="stylesheet" href="/css/code-blocks-buttons.css"/><script type="text/javascript" src="https://buttons.github.io/buttons.js"></script><script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.0/clipboard.min.js"></script><script type="text/javascript" src="/js/custom.js"></script><script src="/js/scrollSpy.js"></script><link rel="stylesheet" href="/css/main.css"/><script src="/js/codetabs.js"></script></head><body class="sideNavVisible separateOnPageNav"><div class="fixedHeaderContainer"><div class="headerWrapper wrapper"><header><a href="/en"><img class="logo" src="/img/pulsar.svg" alt="Apache Pulsar"/></a><a href="/en/versions"><h3>2.10.0</h3></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/en/getting-started-standalone" target="_self">Docs</a></li><li class=""><a href="/en/download" target="_self">Download</a></li><li class="siteNavGroupActive"><a href="/docs/en/client-libraries" target="_self">Clients</a></li><li class=""><a href="#restapis" target="_self">REST APIs</a></li><li class=""><a href="#cli" target="_self">Cli</a></li><li class=""><a href="/blog/" target="_self">Blog</a></li><li class=""><a href="#community" target="_self">Community</a></li><li class=""><a href="#apache" target="_self">Apache</a></li><li class=""><a href="https://pulsar-next.staged.apache.org/" target="_self">New Website (Beta)</a></li><span><li><a id="languages-menu" href="#"><img class="languages-icon" src="/img/language.svg" alt="Languages icon"/>English</a><div id="languages-dropdown" class="hide"><ul id="languages-dropdown-items"><li><a href="/docs/ja/cookbooks-retention-expiry">日本語</a></li><li><a href="/docs/fr/cookbooks-retention-expiry">Français</a></li><li><a href="/docs/ko/cookbooks-retention-expiry">한국어</a></li><li><a href="/docs/zh-CN/cookbooks-retention-expiry">中文</a></li><li><a href="/docs/zh-TW/cookbooks-retention-expiry">繁體中文</a></li><li><a href="https://crowdin.com/project/apache-pulsar" target="_blank" rel="noreferrer noopener">Help Translate</a></li></ul></div></li><script>
const languagesMenuItem = document.getElementById("languages-menu");
const languagesDropDown = document.getElementById("languages-dropdown");
languagesMenuItem.addEventListener("click", function(event) {
event.preventDefault();
if (languagesDropDown.className == "hide") {
languagesDropDown.className = "visible";
} else {
languagesDropDown.className = "hide";
}
});
</script></span></ul></nav></div></header></div></div><div class="navPusher"><div class="docMainWrapper wrapper"><div class="docsNavContainer" id="docsNav"><nav class="toc"><div class="toggleNav"><section class="navWrapper wrapper"><div class="navBreadcrumb wrapper"><div class="navToggle" id="navToggler"><div class="hamburger-menu"><div class="line1"></div><div class="line2"></div><div class="line3"></div></div></div><h2><i></i><span>Cookbooks</span></h2><div class="tocToggler" id="tocToggler"><i class="icon-toc"></i></div></div><div class="navGroups"><div class="navGroup"><h3 class="navGroupCategoryTitle">Get Started</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/getting-started-standalone">Run Pulsar locally</a></li><li class="navListItem"><a class="navItem" href="/docs/en/getting-started-docker">Run Pulsar in Docker</a></li><li class="navListItem"><a class="navItem" href="/docs/en/getting-started-helm">Run Pulsar in Kubernetes</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Concepts and Architecture</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/concepts-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/concepts-messaging">Messaging</a></li><li class="navListItem"><a class="navItem" href="/docs/en/concepts-architecture-overview">Architecture</a></li><li class="navListItem"><a class="navItem" href="/docs/en/concepts-clients">Clients</a></li><li class="navListItem"><a class="navItem" href="/docs/en/concepts-replication">Geo Replication</a></li><li class="navListItem"><a class="navItem" href="/docs/en/concepts-multi-tenancy">Multi Tenancy</a></li><li class="navListItem"><a class="navItem" href="/docs/en/concepts-authentication">Authentication and Authorization</a></li><li class="navListItem"><a class="navItem" href="/docs/en/concepts-topic-compaction">Topic Compaction</a></li><li class="navListItem"><a class="navItem" href="/docs/en/concepts-proxy-sni-routing">Proxy support with SNI routing</a></li><li class="navListItem"><a class="navItem" href="/docs/en/concepts-multiple-advertised-listeners">Multiple advertised listeners</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Pulsar Schema</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/schema-get-started">Get started</a></li><li class="navListItem"><a class="navItem" href="/docs/en/schema-understand">Understand schema</a></li><li class="navListItem"><a class="navItem" href="/docs/en/schema-evolution-compatibility">Schema evolution and compatibility</a></li><li class="navListItem"><a class="navItem" href="/docs/en/schema-manage">Manage schema</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Pulsar Functions</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/functions-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/functions-runtime">Setup: Configure Functions runtime</a></li><li class="navListItem"><a class="navItem" href="/docs/en/functions-worker">Setup: Pulsar Functions Worker</a></li><li class="navListItem"><a class="navItem" href="/docs/en/functions-develop">How-to: Develop</a></li><li class="navListItem"><a class="navItem" href="/docs/en/functions-package">How-to: Package</a></li><li class="navListItem"><a class="navItem" href="/docs/en/functions-debug">How-to: Debug</a></li><li class="navListItem"><a class="navItem" href="/docs/en/functions-deploy">How-to: Deploy</a></li><li class="navListItem"><a class="navItem" href="/docs/en/functions-cli">Reference: CLI</a></li><li class="navListItem"><a class="navItem" href="/docs/en/window-functions-context">Window Functions: Context</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Pulsar IO</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/io-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/io-quickstart">Get started</a></li><li class="navListItem"><a class="navItem" href="/docs/en/io-use">Use</a></li><li class="navListItem"><a class="navItem" href="/docs/en/io-debug">Debug</a></li><li class="navListItem"><a class="navItem" href="/docs/en/io-connectors">Built-in connector</a></li><li class="navListItem"><a class="navItem" href="/docs/en/io-cdc">CDC connector</a></li><li class="navListItem"><a class="navItem" href="/docs/en/io-develop">Develop</a></li><li class="navListItem"><a class="navItem" href="/docs/en/io-cli">CLI</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Pulsar SQL</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/sql-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/sql-getting-started">Query data</a></li><li class="navListItem"><a class="navItem" href="/docs/en/sql-deployment-configurations">Configuration and deployment</a></li><li class="navListItem"><a class="navItem" href="/docs/en/sql-rest-api">REST APIs</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Tiered Storage</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/tiered-storage-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/tiered-storage-aws">AWS S3 offloader</a></li><li class="navListItem"><a class="navItem" href="/docs/en/tiered-storage-gcs">GCS offloader</a></li><li class="navListItem"><a class="navItem" href="/docs/en/tiered-storage-filesystem">Filesystem offloader</a></li><li class="navListItem"><a class="navItem" href="/docs/en/tiered-storage-azure">Azure BlobStore offloader</a></li><li class="navListItem"><a class="navItem" href="/docs/en/tiered-storage-aliyun">Aliyun OSS offloader</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Transactions</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/txn-why">Why transactions?</a></li><li class="navListItem"><a class="navItem" href="/docs/en/txn-what">What are transactions?</a></li><li class="navListItem"><a class="navItem" href="/docs/en/txn-how">How transactions work?</a></li><li class="navListItem"><a class="navItem" href="/docs/en/txn-use">How to use transactions?</a></li><li class="navListItem"><a class="navItem" href="/docs/en/txn-monitor">How to monitor transactions?</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Kubernetes (Helm)</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/helm-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/helm-prepare">Prepare</a></li><li class="navListItem"><a class="navItem" href="/docs/en/helm-install">Install</a></li><li class="navListItem"><a class="navItem" href="/docs/en/helm-deploy">Deployment</a></li><li class="navListItem"><a class="navItem" href="/docs/en/helm-upgrade">Upgrade</a></li><li class="navListItem"><a class="navItem" href="/docs/en/helm-tools">Required Tools</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Deployment</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/deploy-aws">Amazon Web Services</a></li><li class="navListItem"><a class="navItem" href="/docs/en/deploy-kubernetes">Kubernetes</a></li><li class="navListItem"><a class="navItem" href="/docs/en/deploy-bare-metal">Bare metal</a></li><li class="navListItem"><a class="navItem" href="/docs/en/deploy-bare-metal-multi-cluster">Bare metal multi-cluster</a></li><li class="navListItem"><a class="navItem" href="/docs/en/deploy-dcos">DC/OS</a></li><li class="navListItem"><a class="navItem" href="/docs/en/deploy-docker">Docker</a></li><li class="navListItem"><a class="navItem" href="/docs/en/deploy-monitoring">Monitor</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Administration</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/administration-zk-bk">ZooKeeper and BookKeeper</a></li><li class="navListItem"><a class="navItem" href="/docs/en/administration-geo">Geo-replication</a></li><li class="navListItem"><a class="navItem" href="/docs/en/administration-pulsar-manager">Pulsar Manager</a></li><li class="navListItem"><a class="navItem" href="/docs/en/administration-stats">Pulsar statistics</a></li><li class="navListItem"><a class="navItem" href="/docs/en/administration-load-balance">Load balance</a></li><li class="navListItem"><a class="navItem" href="/docs/en/administration-proxy">Pulsar proxy</a></li><li class="navListItem"><a class="navItem" href="/docs/en/administration-upgrade">Upgrade</a></li><li class="navListItem"><a class="navItem" href="/docs/en/administration-isolation">Pulsar isolation</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Security</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/security-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-policy-and-supported-versions">Security Policy and Supported Versions</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-tls-transport">Transport Encryption using TLS</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-tls-authentication">Authentication using TLS</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-tls-keystore">Using TLS with KeyStore configure</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-jwt">Authentication using JWT</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-athenz">Authentication using Athenz</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-kerberos">Authentication using Kerberos</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-oauth2">Authentication using OAuth 2.0 access tokens</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-authorization">Authorization and ACLs</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-encryption">End-to-End Encryption</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-extending">Extend Authentication and Authorization</a></li><li class="navListItem"><a class="navItem" href="/docs/en/security-bouncy-castle">Bouncy Castle Providers</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Performance</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/performance-pulsar-perf">Pulsar Perf</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Client Libraries</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/client-libraries">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/client-libraries-java">Java</a></li><li class="navListItem"><a class="navItem" href="/docs/en/client-libraries-go">Go</a></li><li class="navListItem"><a class="navItem" href="/docs/en/client-libraries-python">Python</a></li><li class="navListItem"><a class="navItem" href="/docs/en/client-libraries-cpp">C++</a></li><li class="navListItem"><a class="navItem" href="/docs/en/client-libraries-node">Node.js</a></li><li class="navListItem"><a class="navItem" href="/docs/en/client-libraries-websocket">WebSocket</a></li><li class="navListItem"><a class="navItem" href="/docs/en/client-libraries-dotnet">C#</a></li><li class="navListItem"><a class="navItem" href="/docs/en/client-libraries-rest">REST</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Admin API</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/admin-api-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/admin-api-clusters">Clusters</a></li><li class="navListItem"><a class="navItem" href="/docs/en/admin-api-tenants">Tenants</a></li><li class="navListItem"><a class="navItem" href="/docs/en/admin-api-brokers">Brokers</a></li><li class="navListItem"><a class="navItem" href="/docs/en/admin-api-namespaces">Namespaces</a></li><li class="navListItem"><a class="navItem" href="/docs/en/admin-api-permissions">Permissions</a></li><li class="navListItem"><a class="navItem" href="/docs/en/admin-api-topics">Topics</a></li><li class="navListItem"><a class="navItem" href="/docs/en/admin-api-functions">Functions</a></li><li class="navListItem"><a class="navItem" href="/docs/en/admin-api-packages">Packages</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Adaptors</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/adaptors-kafka">Kafka client wrapper</a></li><li class="navListItem"><a class="navItem" href="/docs/en/adaptors-spark">Apache Spark</a></li><li class="navListItem"><a class="navItem" href="/docs/en/adaptors-storm">Apache Storm</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Cookbooks</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/cookbooks-compaction">Topic compaction</a></li><li class="navListItem"><a class="navItem" href="/docs/en/cookbooks-deduplication">Message deduplication</a></li><li class="navListItem"><a class="navItem" href="/docs/en/cookbooks-non-persistent">Non-persistent messaging</a></li><li class="navListItem navListItemActive"><a class="navItem" href="/docs/en/cookbooks-retention-expiry">Message retention and expiry</a></li><li class="navListItem"><a class="navItem" href="/docs/en/cookbooks-encryption">Encryption</a></li><li class="navListItem"><a class="navItem" href="/docs/en/cookbooks-message-queue">Message queue</a></li><li class="navListItem"><a class="navItem" href="/docs/en/cookbooks-bookkeepermetadata">BookKeeper Ledger Metadata</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Development</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/develop-tools">Simulation tools</a></li><li class="navListItem"><a class="navItem" href="/docs/en/developing-binary-protocol">Binary protocol</a></li><li class="navListItem"><a class="navItem" href="/docs/en/develop-schema">Custom schema storage</a></li><li class="navListItem"><a class="navItem" href="/docs/en/develop-load-manager">Modular load manager</a></li><li class="navListItem"><a class="navItem" href="/docs/en/develop-plugin">Plugin</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Reference</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/reference-terminology">Terminology</a></li><li class="navListItem"><a class="navItem" href="/docs/en/reference-cli-tools">Pulsar CLI tools</a></li><li class="navListItem"><a class="navItem" href="/docs/en/reference-configuration">Pulsar configuration</a></li><li class="navListItem"><a class="navItem" href="/docs/en/reference-metrics">Pulsar Metrics</a></li></ul></div></div></section></div><script>
var coll = document.getElementsByClassName('collapsible');
var checkActiveCategory = true;
for (var i = 0; i < coll.length; i++) {
var links = coll[i].nextElementSibling.getElementsByTagName('*');
if (checkActiveCategory){
for (var j = 0; j < links.length; j++) {
if (links[j].classList.contains('navListItemActive')){
coll[i].nextElementSibling.classList.toggle('hide');
coll[i].childNodes[1].classList.toggle('rotate');
checkActiveCategory = false;
break;
}
}
}
coll[i].addEventListener('click', function() {
var arrow = this.childNodes[1];
arrow.classList.toggle('rotate');
var content = this.nextElementSibling;
content.classList.toggle('hide');
});
}
document.addEventListener('DOMContentLoaded', function() {
createToggler('#navToggler', '#docsNav', 'docsSliderActive');
createToggler('#tocToggler', 'body', 'tocActive');
var headings = document.querySelector('.toc-headings');
headings && headings.addEventListener('click', function(event) {
var el = event.target;
while(el !== headings){
if (el.tagName === 'A') {
document.body.classList.remove('tocActive');
break;
} else{
el = el.parentNode;
}
}
}, false);
function createToggler(togglerSelector, targetSelector, className) {
var toggler = document.querySelector(togglerSelector);
var target = document.querySelector(targetSelector);
if (!toggler) {
return;
}
toggler.onclick = function(event) {
event.preventDefault();
target.classList.toggle(className);
};
}
});
</script></nav></div><div class="container mainContainer docsContainer"><div class="wrapper"><div class="post"><header class="postHeader"><a class="edit-page-link button" href="https://github.com/apache/pulsar/edit/master/site2/docs/cookbooks-retention-expiry.md" target="_blank" rel="noreferrer noopener">Edit</a><h1 id="__docusaurus" class="postHeaderTitle">Message retention and expiry</h1></header><article><div><span><p>Pulsar brokers are responsible for handling messages that pass through Pulsar, including <a href="/docs/en/concepts-architecture-overview#persistent-storage">persistent storage</a> of messages. By default, for each topic, brokers only retain messages that are in at least one backlog. A backlog is the set of unacknowledged messages for a particular subscription. As a topic can have multiple subscriptions, a topic can have multiple backlogs.</p>
<p>As a consequence, no messages are retained (by default) on a topic that has not had any subscriptions created for it.</p>
<p>(Note that messages that are no longer being stored are not necessarily immediately deleted, and may in fact still be accessible until the next ledger rollover. Because clients cannot predict when rollovers may happen, it is not wise to rely on a rollover not happening at an inconvenient point in time.)</p>
<p>In Pulsar, you can modify this behavior, with namespace granularity, in two ways:</p>
<ul>
<li>You can persistently store messages that are not within a backlog (because they've been acknowledged by on every existing subscription, or because there are no subscriptions) by setting <a href="#retention-policies">retention policies</a>.</li>
<li>Messages that are not acknowledged within a specified timeframe can be automatically acknowledged, by specifying the <a href="#time-to-live-ttl">time to live</a> (TTL).</li>
</ul>
<p>Pulsar's <a href="/docs/en/admin-api-overview">admin interface</a> enables you to manage both retention policies and TTL with namespace granularity (and thus within a specific tenant and either on a specific cluster or in the <a href="/docs/en/concepts-architecture-overview#global-cluster"><code>global</code></a> cluster).</p>
<blockquote>
<h4><a class="anchor" aria-hidden="true" id="retention-and-ttl-solve-two-different-problems"></a><a href="#retention-and-ttl-solve-two-different-problems" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Retention and TTL solve two different problems</h4>
<ul>
<li>Message retention: Keep the data for at least X hours (even if acknowledged)</li>
<li>Time-to-live: Discard data after some time (by automatically acknowledging)</li>
</ul>
<p>Most applications will want to use at most one of these.</p>
</blockquote>
<h2><a class="anchor" aria-hidden="true" id="retention-policies"></a><a href="#retention-policies" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Retention policies</h2>
<p>By default, when a Pulsar message arrives at a broker, the message is stored until it has been acknowledged on all subscriptions, at which point it is marked for deletion. You can override this behavior and retain messages that have already been acknowledged on all subscriptions by setting a <em>retention policy</em> for all topics in a given namespace. Retention is based on both a <em>size limit</em> and a <em>time limit</em>.</p>
<p>The diagram below illustrates the concept of message retention.
<img src="/docs/assets/retention.svg" alt=""></p>
<p>Retention policies are useful when you use the Reader interface. The Reader interface does not use acknowledgements, and messages do not exist within backlogs. It is required to configure retention for Reader-only use cases.</p>
<p>When you set a retention policy on topics in a namespace, you must set <strong>both</strong> a <em>size limit</em> (via <code>defaultRetentionSizeInMB</code>) and a <em>time limit</em> (via <code>defaultRetentionTimeInMinutes</code>) . You can refer to the following table to set retention policies in <code>pulsar-admin</code> and Java.</p>
<table>
<thead>
<tr><th>Time limit</th><th>Size limit</th><th>Message retention</th></tr>
</thead>
<tbody>
<tr><td>-1</td><td>-1</td><td>Infinite retention</td></tr>
<tr><td>-1</td><td>&gt;0</td><td>Based on the size limit</td></tr>
<tr><td>&gt;0</td><td>-1</td><td>Based on the time limit</td></tr>
<tr><td>0</td><td>0</td><td>Disable message retention (by default)</td></tr>
<tr><td>0</td><td>&gt;0</td><td>Invalid</td></tr>
<tr><td>&gt;0</td><td>0</td><td>Invalid</td></tr>
<tr><td>&gt;0</td><td>&gt;0</td><td>Acknowledged messages or messages with no active subscription will not be retained when either time or size reaches the limit.</td></tr>
</tbody>
</table>
<p>The retention settings apply to all messages on topics that do not have any subscriptions, or to messages that have been acknowledged by all subscriptions. The retention policy settings do not affect unacknowledged messages on topics with subscriptions. The unacknowledged messages are controlled by the backlog quota.</p>
<p>When a retention limit on a topic is exceeded, the oldest message is marked for deletion until the set of retained messages falls within the specified limits again.</p>
<h3><a class="anchor" aria-hidden="true" id="defaults"></a><a href="#defaults" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Defaults</h3>
<p>You can set message retention at instance level with the following two parameters: <code>defaultRetentionTimeInMinutes</code> and <code>defaultRetentionSizeInMB</code>. Both parameters are set to <code>0</code> by default.</p>
<p>For more information of the two parameters, refer to the <a href="/docs/en/reference-configuration#broker"><code>broker.conf</code></a> configuration file.</p>
<h3><a class="anchor" aria-hidden="true" id="set-retention-policy"></a><a href="#set-retention-policy" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Set retention policy</h3>
<p>You can set a retention policy for a namespace by specifying the namespace, a size limit and a time limit in <code>pulsar-admin</code>, REST API and Java.</p>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-980-tab-981" class="nav-link active" data-group="group_980" data-tab="tab-group-980-content-981">pulsar-admin</div><div id="tab-group-980-tab-982" class="nav-link" data-group="group_980" data-tab="tab-group-980-content-982">REST API</div><div id="tab-group-980-tab-983" class="nav-link" data-group="group_980" data-tab="tab-group-980-content-983">Java</div></div><div class="tab-content"><div id="tab-group-980-content-981" class="tab-pane active" data-group="group_980" tabindex="-1"><div><span><p>You can use the <a href="/docs/en/reference-pulsar-admin#namespaces-set-retention"><code>set-retention</code></a> subcommand and specify a namespace, a size limit using the <code>-s</code>/<code>--size</code> flag, and a time limit using the <code>-t</code>/<code>--time</code> flag.</p>
<p>In the following example, the size limit is set to 10 GB and the time limit is set to 3 hours for each topic within the <code>my-tenant/my-ns</code> namespace.</p>
<ul>
<li>When the size of messages reaches 10 GB on a topic within 3 hours, the acknowledged messages will not be retained.</li>
<li>After 3 hours, even if the message size is less than 10 GB, the acknowledged messages will not be retained.</li>
</ul>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces <span class="hljs-built_in">set</span>-retention my-tenant/my-ns \</span><br /> --size 10G \<br /> --time 3h<br /></code></pre>
<p>In the following example, the time is not limited and the size limit is set to 1 TB. The size limit determines the retention.</p>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces <span class="hljs-built_in">set</span>-retention my-tenant/my-ns \</span><br /> --size 1T \<br /> --time -1<br /></code></pre>
<p>In the following example, the size is not limited and the time limit is set to 3 hours. The time limit determines the retention.</p>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces <span class="hljs-built_in">set</span>-retention my-tenant/my-ns \</span><br /> --size -1 \<br /> --time 3h<br /></code></pre>
<p>To achieve infinite retention, set both values to <code>-1</code>.</p>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces <span class="hljs-built_in">set</span>-retention my-tenant/my-ns \</span><br /> --size -1 \<br /> --time -1<br /></code></pre>
<p>To disable the retention policy, set both values to <code>0</code>.</p>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces <span class="hljs-built_in">set</span>-retention my-tenant/my-ns \</span><br /> --size 0 \<br /> --time 0<br /></code></pre>
</span></div></div><div id="tab-group-980-content-982" class="tab-pane" data-group="group_980" tabindex="-1"><div><span><p><a href="https://pulsar.apache.org/admin-rest-api#operation/setRetention?version=2.10.0&amp;apiVersion=v2"><b>POST</b> <i>/admin/v2/namespaces/:tenant/:namespace/retention</i></a>
</p>
<blockquote>
<p><strong>Note</strong> <br>
To disable the retention policy, you need to set both the size and time limit to <code>0</code>. Set either size or time limit to <code>0</code> is invalid.</p>
</blockquote>
</span></div></div><div id="tab-group-980-content-983" class="tab-pane" data-group="group_980" tabindex="-1"><div><span><pre><code class="hljs css language-java"><span class="hljs-keyword">int</span> retentionTime = <span class="hljs-number">10</span>; <span class="hljs-comment">// 10 minutes</span><br /><span class="hljs-keyword">int</span> retentionSize = <span class="hljs-number">500</span>; <span class="hljs-comment">// 500 megabytes</span><br />RetentionPolicies policies = <span class="hljs-keyword">new</span> RetentionPolicies(retentionTime, retentionSize);<br />admin.namespaces().setRetention(namespace, policies);<br /></code></pre>
</span></div></div></div></div>
<h3><a class="anchor" aria-hidden="true" id="get-retention-policy"></a><a href="#get-retention-policy" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Get retention policy</h3>
<p>You can fetch the retention policy for a namespace by specifying the namespace. The output will be a JSON object with two keys: <code>retentionTimeInMinutes</code> and <code>retentionSizeInMB</code>.</p>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-984-tab-985" class="nav-link active" data-group="group_984" data-tab="tab-group-984-content-985">pulsar-admin</div><div id="tab-group-984-tab-986" class="nav-link" data-group="group_984" data-tab="tab-group-984-content-986">REST API</div><div id="tab-group-984-tab-987" class="nav-link" data-group="group_984" data-tab="tab-group-984-content-987">Java</div></div><div class="tab-content"><div id="tab-group-984-content-985" class="tab-pane active" data-group="group_984" tabindex="-1"><div><span><p>Use the <a href="/docs/en/reference-pulsar-admin#namespaces"><code>get-retention</code></a> subcommand and specify the namespace.</p>
<h5><a class="anchor" aria-hidden="true" id="example"></a><a href="#example" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Example</h5>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces get-retention my-tenant/my-ns</span><br />{<br /> "retentionTimeInMinutes": 10,<br /> "retentionSizeInMB": 500<br />}<br /></code></pre>
</span></div></div><div id="tab-group-984-content-986" class="tab-pane" data-group="group_984" tabindex="-1"><div><span><p><a href="https://pulsar.apache.org/admin-rest-api#operation/getRetention?version=2.10.0&amp;apiVersion=v2"><b>GET</b> <i>/admin/v2/namespaces/:tenant/:namespace/retention</i></a>
</p>
</span></div></div><div id="tab-group-984-content-987" class="tab-pane" data-group="group_984" tabindex="-1"><div><span><pre><code class="hljs css language-java">admin.namespaces().getRetention(namespace);<br /></code></pre>
</span></div></div></div></div>
<h2><a class="anchor" aria-hidden="true" id="backlog-quotas"></a><a href="#backlog-quotas" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Backlog quotas</h2>
<p><em>Backlogs</em> are sets of unacknowledged messages for a topic that have been stored by bookies. Pulsar stores all unacknowledged messages in backlogs until they are processed and acknowledged.</p>
<p>You can control the allowable size and/or time of backlogs, at the namespace level, using <em>backlog quotas</em>. Pulsar uses a quota to enforce a hard limit on the logical size of the backlogs in a topic. Backlog quota triggers an alert policy (for example, producer exception) once the quota limit is reached.</p>
<p>The diagram below illustrates the concept of backlog quota.
<img src="/docs/assets/backlog-quota.svg" alt=""></p>
<p>Setting a backlog quota involves setting:</p>
<ul>
<li>an allowable <em>size and/or time threshold</em> for each topic in the namespace</li>
<li>a <em>retention policy</em> that determines which action the <a href="/docs/en/reference-terminology#broker">broker</a> takes if the threshold is exceeded.</li>
</ul>
<p>The following retention policies are available:</p>
<table>
<thead>
<tr><th style="text-align:left">Policy</th><th style="text-align:left">Action</th></tr>
</thead>
<tbody>
<tr><td style="text-align:left"><code>producer_request_hold</code></td><td style="text-align:left">The broker will hold and not persist produce request payload</td></tr>
<tr><td style="text-align:left"><code>producer_exception</code></td><td style="text-align:left">The broker will disconnect from the client by throwing an exception</td></tr>
<tr><td style="text-align:left"><code>consumer_backlog_eviction</code></td><td style="text-align:left">The broker will begin discarding backlog messages</td></tr>
</tbody>
</table>
<blockquote>
<h4><a class="anchor" aria-hidden="true" id="beware-the-distinction-between-retention-policy-types"></a><a href="#beware-the-distinction-between-retention-policy-types" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Beware the distinction between retention policy types</h4>
<p>As you may have noticed, there are two definitions of the term &quot;retention policy&quot; in Pulsar, one that applies to persistent storage of messages not in backlogs, and one that applies to messages within backlogs.</p>
</blockquote>
<p>Backlog quotas are handled at the namespace level. They can be managed via:</p>
<h3><a class="anchor" aria-hidden="true" id="set-sizetime-thresholds-and-backlog-retention-policies"></a><a href="#set-sizetime-thresholds-and-backlog-retention-policies" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Set size/time thresholds and backlog retention policies</h3>
<p>You can set a size and/or time threshold and backlog retention policy for all of the topics in a <a href="/docs/en/reference-terminology#namespace">namespace</a> by specifying the namespace, a size limit and/or a time limit in second, and a policy by name.</p>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-988-tab-989" class="nav-link active" data-group="group_988" data-tab="tab-group-988-content-989">pulsar-admin</div><div id="tab-group-988-tab-990" class="nav-link" data-group="group_988" data-tab="tab-group-988-content-990">REST API</div><div id="tab-group-988-tab-991" class="nav-link" data-group="group_988" data-tab="tab-group-988-content-991">Java</div></div><div class="tab-content"><div id="tab-group-988-content-989" class="tab-pane active" data-group="group_988" tabindex="-1"><div><span><p>Use the <a href="/docs/en/reference-pulsar-admin#namespaces"><code>set-backlog-quota</code></a> subcommand and specify a namespace, a size limit using the <code>-l</code>/<code>--limit</code> , <code>-lt</code>/<code>--limitTime</code> flag to limit backlog, a retention policy using the <code>-p</code>/<code>--policy</code> flag and a policy type using <code>-t</code>/<code>--type</code> (default is destination_storage).</p>
<h5><a class="anchor" aria-hidden="true" id="example"></a><a href="#example" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Example</h5>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces <span class="hljs-built_in">set</span>-backlog-quota my-tenant/my-ns \</span><br /> --limit 2G \<br /> --policy producer_request_hold<br /></code></pre>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces <span class="hljs-built_in">set</span>-backlog-quota my-tenant/my-ns/my-topic \</span><br />--limitTime 3600 \<br />--policy producer_request_hold \<br />--type message_age<br /></code></pre>
</span></div></div><div id="tab-group-988-content-990" class="tab-pane" data-group="group_988" tabindex="-1"><div><span><p><a href="https://pulsar.apache.org/admin-rest-api#operation/getBacklogQuotaMap?version=2.10.0&amp;apiVersion=v2"><b>POST</b> <i>/admin/v2/namespaces/:tenant/:namespace/backlogQuota</i></a>
</p>
</span></div></div><div id="tab-group-988-content-991" class="tab-pane" data-group="group_988" tabindex="-1"><div><span><pre><code class="hljs css language-java"><span class="hljs-keyword">long</span> sizeLimit = <span class="hljs-number">2147483648L</span>;<br />BacklogQuota.RetentionPolicy policy = BacklogQuota.RetentionPolicy.producer_request_hold;<br />BacklogQuota quota = <span class="hljs-keyword">new</span> BacklogQuota(sizeLimit, policy);<br />admin.namespaces().setBacklogQuota(namespace, quota);<br /></code></pre>
</span></div></div></div></div>
<h3><a class="anchor" aria-hidden="true" id="get-backlog-threshold-and-backlog-retention-policy"></a><a href="#get-backlog-threshold-and-backlog-retention-policy" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Get backlog threshold and backlog retention policy</h3>
<p>You can see which size threshold and backlog retention policy has been applied to a namespace.</p>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-992-tab-993" class="nav-link active" data-group="group_992" data-tab="tab-group-992-content-993">pulsar-admin</div><div id="tab-group-992-tab-994" class="nav-link" data-group="group_992" data-tab="tab-group-992-content-994">REST API</div><div id="tab-group-992-tab-995" class="nav-link" data-group="group_992" data-tab="tab-group-992-content-995">Java</div></div><div class="tab-content"><div id="tab-group-992-content-993" class="tab-pane active" data-group="group_992" tabindex="-1"><div><span><p>Use the <a href="/docs/en/reference-pulsar-admin#pulsar-admin-namespaces-get-backlog-quotas"><code>get-backlog-quotas</code></a> subcommand and specify a namespace. Here's an example:</p>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces get-backlog-quotas my-tenant/my-ns</span><br />{<br /> "destination_storage": {<br /> "limit" : 2147483648,<br /> "policy" : "producer_request_hold"<br /> }<br />}<br /></code></pre>
</span></div></div><div id="tab-group-992-content-994" class="tab-pane" data-group="group_992" tabindex="-1"><div><span><p><a href="https://pulsar.apache.org/admin-rest-api#operation/getBacklogQuotaMap?version=2.10.0&amp;apiVersion=v2"><b>GET</b> <i>/admin/v2/namespaces/:tenant/:namespace/backlogQuotaMap</i></a>
</p>
</span></div></div><div id="tab-group-992-content-995" class="tab-pane" data-group="group_992" tabindex="-1"><div><span><pre><code class="hljs css language-java">Map&lt;BacklogQuota.BacklogQuotaType,BacklogQuota&gt; quotas =<br /> admin.namespaces().getBacklogQuotas(namespace);<br /></code></pre>
</span></div></div></div></div>
<h3><a class="anchor" aria-hidden="true" id="remove-backlog-quotas"></a><a href="#remove-backlog-quotas" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Remove backlog quotas</h3>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-996-tab-997" class="nav-link active" data-group="group_996" data-tab="tab-group-996-content-997">pulsar-admin</div><div id="tab-group-996-tab-998" class="nav-link" data-group="group_996" data-tab="tab-group-996-content-998">REST API</div><div id="tab-group-996-tab-999" class="nav-link" data-group="group_996" data-tab="tab-group-996-content-999">Java</div></div><div class="tab-content"><div id="tab-group-996-content-997" class="tab-pane active" data-group="group_996" tabindex="-1"><div><span><p>Use the <a href="/docs/en/reference-pulsar-admin#pulsar-admin-namespaces-remove-backlog-quota"><code>remove-backlog-quota</code></a> subcommand and specify a namespace, use <code>t</code>/<code>--type</code> to specify backlog type to remove(default is destination_storage). Here's an example:</p>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces remove-backlog-quota my-tenant/my-ns</span><br /></code></pre>
</span></div></div><div id="tab-group-996-content-998" class="tab-pane" data-group="group_996" tabindex="-1"><div><span><p><a href="https://pulsar.apache.org/admin-rest-api#operation/removeBacklogQuota?version=2.10.0&amp;apiVersion=v2"><b>DELETE</b> <i>/admin/v2/namespaces/:tenant/:namespace/backlogQuota</i></a>
</p>
</span></div></div><div id="tab-group-996-content-999" class="tab-pane" data-group="group_996" tabindex="-1"><div><span><pre><code class="hljs css language-java">admin.namespaces().removeBacklogQuota(namespace);<br /></code></pre>
</span></div></div></div></div>
<h3><a class="anchor" aria-hidden="true" id="clear-backlog"></a><a href="#clear-backlog" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Clear backlog</h3>
<h4><a class="anchor" aria-hidden="true" id="pulsar-admin"></a><a href="#pulsar-admin" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>pulsar-admin</h4>
<p>Use the <a href="/docs/en/reference-pulsar-admin#pulsar-admin-namespaces-clear-backlog"><code>clear-backlog</code></a> subcommand.</p>
<h5><a class="anchor" aria-hidden="true" id="example"></a><a href="#example" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Example</h5>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces clear-backlog my-tenant/my-ns</span>
</code></pre>
<p>By default, you will be prompted to ensure that you really want to clear the backlog for the namespace. You can override the prompt using the <code>-f</code>/<code>--force</code> flag.</p>
<h2><a class="anchor" aria-hidden="true" id="time-to-live-ttl"></a><a href="#time-to-live-ttl" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Time to live (TTL)</h2>
<p>By default, Pulsar stores all unacknowledged messages forever. This can lead to heavy disk space usage in cases where a lot of messages are going unacknowledged. If disk space is a concern, you can set a time to live (TTL) that determines how long unacknowledged messages will be retained.</p>
<p>The TTL parameter is like a stopwatch attached to each message that defines the amount of time a message is allowed to stay in the unacknowledged state. When the TTL expires, Pulsar automatically moves the message to the acknowledged state (and thus makes it ready for deletion).</p>
<p>The diagram below illustrates the concept of TTL.
<img src="/docs/assets/ttl.svg" alt=""></p>
<h3><a class="anchor" aria-hidden="true" id="set-the-ttl-for-a-namespace"></a><a href="#set-the-ttl-for-a-namespace" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Set the TTL for a namespace</h3>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-1000-tab-1001" class="nav-link active" data-group="group_1000" data-tab="tab-group-1000-content-1001">pulsar-admin</div><div id="tab-group-1000-tab-1002" class="nav-link" data-group="group_1000" data-tab="tab-group-1000-content-1002">REST API</div><div id="tab-group-1000-tab-1003" class="nav-link" data-group="group_1000" data-tab="tab-group-1000-content-1003">Java</div></div><div class="tab-content"><div id="tab-group-1000-content-1001" class="tab-pane active" data-group="group_1000" tabindex="-1"><div><span><p>Use the <a href="/docs/en/reference-pulsar-admin#pulsar-admin-namespaces-set-message-ttl"><code>set-message-ttl</code></a> subcommand and specify a namespace and a TTL (in seconds) using the <code>-ttl</code>/<code>--messageTTL</code> flag.</p>
<h5><a class="anchor" aria-hidden="true" id="example"></a><a href="#example" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Example</h5>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces <span class="hljs-built_in">set</span>-message-ttl my-tenant/my-ns \</span><br /> --messageTTL 120 # TTL of 2 minutes<br /></code></pre>
</span></div></div><div id="tab-group-1000-content-1002" class="tab-pane" data-group="group_1000" tabindex="-1"><div><span><p><a href="https://pulsar.apache.org/admin-rest-api#operation/setNamespaceMessageTTL?version=2.10.0&amp;apiVersion=v2"><b>POST</b> <i>/admin/v2/namespaces/:tenant/:namespace/messageTTL</i></a>
</p>
</span></div></div><div id="tab-group-1000-content-1003" class="tab-pane" data-group="group_1000" tabindex="-1"><div><span><pre><code class="hljs css language-java">admin.namespaces().setNamespaceMessageTTL(namespace, ttlInSeconds);<br /></code></pre>
</span></div></div></div></div>
<h3><a class="anchor" aria-hidden="true" id="get-the-ttl-configuration-for-a-namespace"></a><a href="#get-the-ttl-configuration-for-a-namespace" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Get the TTL configuration for a namespace</h3>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-1004-tab-1005" class="nav-link active" data-group="group_1004" data-tab="tab-group-1004-content-1005">pulsar-admin</div><div id="tab-group-1004-tab-1006" class="nav-link" data-group="group_1004" data-tab="tab-group-1004-content-1006">REST API</div><div id="tab-group-1004-tab-1007" class="nav-link" data-group="group_1004" data-tab="tab-group-1004-content-1007">Java</div></div><div class="tab-content"><div id="tab-group-1004-content-1005" class="tab-pane active" data-group="group_1004" tabindex="-1"><div><span><p>Use the <a href="/docs/en/reference-pulsar-admin#pulsar-admin-namespaces-get-message-ttl"><code>get-message-ttl</code></a> subcommand and specify a namespace.</p>
<h5><a class="anchor" aria-hidden="true" id="example"></a><a href="#example" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Example</h5>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces get-message-ttl my-tenant/my-ns</span><br />60<br /></code></pre>
</span></div></div><div id="tab-group-1004-content-1006" class="tab-pane" data-group="group_1004" tabindex="-1"><div><span><p><a href="https://pulsar.apache.org/admin-rest-api#operation/getNamespaceMessageTTL?version=2.10.0&amp;apiVersion=v2"><b>GET</b> <i>/admin/v2/namespaces/:tenant/:namespace/messageTTL</i></a>
</p>
</span></div></div><div id="tab-group-1004-content-1007" class="tab-pane" data-group="group_1004" tabindex="-1"><div><span><pre><code class="hljs css language-java">admin.namespaces().getNamespaceMessageTTL(namespace)<br /></code></pre>
</span></div></div></div></div>
<h3><a class="anchor" aria-hidden="true" id="remove-the-ttl-configuration-for-a-namespace"></a><a href="#remove-the-ttl-configuration-for-a-namespace" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Remove the TTL configuration for a namespace</h3>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-1008-tab-1009" class="nav-link active" data-group="group_1008" data-tab="tab-group-1008-content-1009">pulsar-admin</div><div id="tab-group-1008-tab-1010" class="nav-link" data-group="group_1008" data-tab="tab-group-1008-content-1010">REST API</div><div id="tab-group-1008-tab-1011" class="nav-link" data-group="group_1008" data-tab="tab-group-1008-content-1011">Java</div></div><div class="tab-content"><div id="tab-group-1008-content-1009" class="tab-pane active" data-group="group_1008" tabindex="-1"><div><span><p>Use the <a href="/docs/en/reference-pulsar-admin#pulsar-admin-namespaces-remove-message-ttl"><code>remove-message-ttl</code></a> subcommand and specify a namespace.</p>
<h5><a class="anchor" aria-hidden="true" id="example"></a><a href="#example" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Example</h5>
<pre><code class="hljs css language-shell"><span class="hljs-meta">$</span><span class="bash"> pulsar-admin namespaces remove-message-ttl my-tenant/my-ns</span><br /></code></pre>
</span></div></div><div id="tab-group-1008-content-1010" class="tab-pane" data-group="group_1008" tabindex="-1"><div><span><p><a href="https://pulsar.apache.org/admin-rest-api#operation/removeNamespaceMessageTTL?version=2.10.0&amp;apiVersion=v2"><b>DELETE</b> <i>/admin/v2/namespaces/:tenant/:namespace/messageTTL</i></a>
</p>
</span></div></div><div id="tab-group-1008-content-1011" class="tab-pane" data-group="group_1008" tabindex="-1"><div><span><pre><code class="hljs css language-java">admin.namespaces().removeNamespaceMessageTTL(namespace)<br /></code></pre>
</span></div></div></div></div>
<h2><a class="anchor" aria-hidden="true" id="delete-messages-from-namespaces"></a><a href="#delete-messages-from-namespaces" aria-hidden="true" class="hash-link"><svg class="hash-link-icon" aria-hidden="true" height="16" version="1.1" viewBox="0 0 16 16" width="16"><path fill-rule="evenodd" d="M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z"></path></svg></a>Delete messages from namespaces</h2>
<p>When it comes to the physical storage size, message expiry and retention are just like two sides of the same coin.</p>
<ul>
<li>The backlog quota and TTL parameters prevent disk size from growing indefinitely, as Pulsar’s default behaviour is to persist unacknowledged messages.</li>
<li>The retention policy allocates storage space to accommodate the messages that are supposed to be deleted by Pulsar by default.</li>
</ul>
<p>As a conclusion, the size of your physical storage should accommodate the sum of the backlog quota and the retention size.</p>
<p>The message deletion rate (releasing rate of disk space) can be determined by multiple factors.</p>
<ul>
<li><p><strong>Segment rollover period</strong>: basically, the segment rollover period is how often a new segment is created. Once a new segment is created, the old segment will be deleted. By default, this happens either when you have written 50,000 entries (messages) or have waited 240 minutes. You can tune this in your broker.</p></li>
<li><p><strong>Entry log rollover period</strong>: multiple ledgers in BookKeeper are interleaved into an <a href="https://bookkeeper.apache.org/docs/4.11.1/getting-started/concepts/#entry-logs">entry log</a>. In order for a ledger that has been deleted, the entry log must all be rolled over.
The entry log rollover period is configurable, but is purely based on the entry log size. For details, see <a href="https://bookkeeper.apache.org/docs/4.11.1/reference/config/#entry-log-settings">here</a>. Once the entry log is rolled over, the entry log can be garbage collected.</p></li>
<li><p><strong>Garbage collection interval</strong>: because entry logs have interleaved ledgers, to free up space, the entry logs need to be rewritten. The garbage collection interval is how often BookKeeper performs garbage collection. which is related to minor compaction and major compaction of entry logs. For details, see <a href="https://bookkeeper.apache.org/docs/4.11.1/reference/config/#entry-log-compaction-settings">here</a>.</p></li>
</ul>
<p>The diagram below illustrates one of the cases that the consumed storage size is larger than the given limits for backlog and retention. Messages over the retention limit are kept because other messages in the same segment are still within retention period.
<img src="/docs/assets/retention-storage-size.svg" alt=""></p>
<p>If you do not have any retention period and that you never have much of a backlog, the upper limit for retained messages, which are acknowledged, equals to the Pulsar segment rollover period + entry log rollover period + (garbage collection interval * garbage collection ratios).</p>
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/en/cookbooks-non-persistent"><span class="arrow-prev"></span><span>Non-persistent messaging</span></a><a class="docs-next button" href="/docs/en/cookbooks-encryption"><span>Encryption</span><span class="arrow-next"></span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#retention-policies">Retention policies</a><ul class="toc-headings"><li><a href="#defaults">Defaults</a></li><li><a href="#set-retention-policy">Set retention policy</a></li><li><a href="#get-retention-policy">Get retention policy</a></li></ul></li><li><a href="#backlog-quotas">Backlog quotas</a><ul class="toc-headings"><li><a href="#set-sizetime-thresholds-and-backlog-retention-policies">Set size/time thresholds and backlog retention policies</a></li><li><a href="#get-backlog-threshold-and-backlog-retention-policy">Get backlog threshold and backlog retention policy</a></li><li><a href="#remove-backlog-quotas">Remove backlog quotas</a></li><li><a href="#clear-backlog">Clear backlog</a></li></ul></li><li><a href="#time-to-live-ttl">Time to live (TTL)</a><ul class="toc-headings"><li><a href="#set-the-ttl-for-a-namespace">Set the TTL for a namespace</a></li><li><a href="#get-the-ttl-configuration-for-a-namespace">Get the TTL configuration for a namespace</a></li><li><a href="#remove-the-ttl-configuration-for-a-namespace">Remove the TTL configuration for a namespace</a></li></ul></li><li><a href="#delete-messages-from-namespaces">Delete messages from namespaces</a></li></ul></nav></div><footer class="nav-footer" id="footer"><section class="copyright">Copyright © 2022 The Apache Software Foundation. All Rights Reserved. Apache, Apache Pulsar and the Apache feather logo are trademarks of The Apache Software Foundation.</section><span><script>
const community = document.querySelector("a[href='#community']").parentNode;
const communityMenu =
'<li>' +
'<a id="community-menu" href="#">Community <span style="font-size: 0.75em">&nbsp;▼</span></a>' +
'<div id="community-dropdown" class="hide">' +
'<ul id="community-dropdown-items">' +
'<li><a href="/en/contact">Contact</a></li>' +
'<li><a href="/en/contributing">Contributing</a></li>' +
'<li><a href="/en/coding-guide">Coding guide</a></li>' +
'<li><a href="/en/events">Events</a></li>' +
'<li><a href="https://twitter.com/Apache_Pulsar" target="_blank">Twitter &#x2750</a></li>' +
'<li><a href="https://github.com/apache/pulsar/wiki" target="_blank">Wiki &#x2750</a></li>' +
'<li><a href="https://github.com/apache/pulsar/issues" target="_blank">Issue tracking &#x2750</a></li>' +
'<li><a href="https://pulsar-summit.org/" target="_blank">Pulsar Summit &#x2750</a></li>' +
'<li>&nbsp;</li>' +
'<li><a href="/en/resources">Resources</a></li>' +
'<li><a href="/en/team">Team</a></li>' +
'<li><a href="/en/powered-by">Powered By</a></li>' +
'</ul>' +
'</div>' +
'</li>';
community.innerHTML = communityMenu;
const communityMenuItem = document.getElementById("community-menu");
const communityDropDown = document.getElementById("community-dropdown");
communityMenuItem.addEventListener("click", function(event) {
event.preventDefault();
if (communityDropDown.className == 'hide') {
communityDropDown.className = 'visible';
} else {
communityDropDown.className = 'hide';
}
});
</script></span></footer></div><script>window.twttr=(function(d,s, id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src='https://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js, fjs);t._e = [];t.ready = function(f) {t._e.push(f);};return t;}(document, 'script', 'twitter-wjs'));</script></body></html>