blob: 549569ee29fd66cbc2bd67f09f9c3346b9840576 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charSet="utf-8"/><meta http-equiv="X-UA-Compatible" content="IE=edge"/><title>Manage schema · Apache Pulsar</title><meta name="viewport" content="width=device-width, initial-scale=1.0"/><meta name="generator" content="Docusaurus"/><meta name="description" content="This guide demonstrates the ways to manage schemas:"/><meta name="docsearch:version" content="2.6.4"/><meta name="docsearch:language" content="en"/><meta property="og:title" content="Manage schema · Apache Pulsar"/><meta property="og:type" content="website"/><meta property="og:url" content="https://pulsar.apache.org/"/><meta property="og:description" content="This guide demonstrates the ways to manage schemas:"/><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.6.4</h3></a><div class="navigationWrapper navigationSlider"><nav class="slidingNav"><ul class="nav-site nav-site-internal"><li class="siteNavGroupActive"><a href="/docs/en/2.6.4/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/2.6.4/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/2.6.4/schema-manage">日本語</a></li><li><a href="/docs/fr/2.6.4/schema-manage">Français</a></li><li><a href="/docs/ko/2.6.4/schema-manage">한국어</a></li><li><a href="/docs/zh-CN/2.6.4/schema-manage">中文</a></li><li><a href="/docs/zh-TW/2.6.4/schema-manage">繁體中文</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>Pulsar Schema</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/2.6.4/pulsar-2.0">Pulsar 2.0</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/getting-started-standalone">Run Pulsar locally</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/getting-started-docker">Run Pulsar in Docker</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/getting-started-helm">Run Pulsar in Kubernetes</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/client-libraries">Use Pulsar with client libraries</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/2.6.4/concepts-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/concepts-messaging">Messaging</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/concepts-architecture-overview">Architecture</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/concepts-clients">Clients</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/concepts-replication">Geo Replication</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/concepts-multi-tenancy">Multi Tenancy</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/concepts-authentication">Authentication and Authorization</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/concepts-topic-compaction">Topic Compaction</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/concepts-tiered-storage">Tiered Storage</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/concepts-proxy-sni-routing">Proxy support with SNI routing</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Pulsar Schema</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/schema-get-started">Get started</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/schema-understand">Understand schema</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/schema-evolution-compatibility">Schema evolution and compatibility</a></li><li class="navListItem navListItemActive"><a class="navItem" href="/docs/en/2.6.4/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/2.6.4/functions-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/functions-worker">Setup: Pulsar Functions Worker</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/functions-runtime">Setup: Configure Functions runtime</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/functions-develop">How-to: Develop</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/functions-debug">How-to: Debug</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/functions-deploy">How-to: Deploy</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/functions-cli">Reference: CLI</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/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/2.6.4/io-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/io-quickstart">Get started</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/io-use">Use</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/io-debug">Debug</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/io-connectors">Built-in connector</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/io-cdc">CDC connector</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/io-develop">Develop</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/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/2.6.4/sql-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/sql-getting-started">Query data</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/sql-deployment-configurations">Configuration and deployment</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/sql-rest-api">REST APIs</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Kubernetes (Helm)</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/helm-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/helm-prepare">Prepare</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/helm-install">Install</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/helm-deploy">Deployment</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/helm-upgrade">Upgrade</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/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/2.6.4/deploy-aws">Amazon Web Services</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/deploy-kubernetes">Kubernetes</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/deploy-bare-metal">Bare metal</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/deploy-bare-metal-multi-cluster">Bare metal multi-cluster</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/deploy-monitoring">Monitoring</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Administration</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/administration-zk-bk">ZooKeeper and BookKeeper</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/administration-geo">Geo-replication</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/administration-pulsar-manager">Pulsar Manager</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/administration-stats">Pulsar statistics</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/administration-load-balance">Load balance</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/administration-proxy">Pulsar proxy</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/administration-upgrade">Upgrade</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Security</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/security-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/security-tls-transport">Transport Encryption using TLS</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/security-tls-authentication">Authentication using TLS</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/security-tls-keystore">Using TLS with KeyStore configure</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/security-jwt">Authentication using JWT</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/security-athenz">Authentication using Athenz</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/security-kerberos">Authentication using Kerberos</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/security-oauth2">Authentication using OAuth 2.0 access tokens</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/security-authorization">Authorization and ACLs</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/security-encryption">End-to-End Encryption</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/security-extending">Extending</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/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/2.6.4/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/2.6.4/client-libraries-java">Java</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/client-libraries-go">Go</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/client-libraries-python">Python</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/client-libraries-cpp">C++</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/client-libraries-node">Node.js</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/client-libraries-websocket">WebSocket</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/client-libraries-dotnet">C#</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Admin API</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-overview">Overview</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-clusters">Clusters</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-tenants">Tenants</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-brokers">Brokers</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-namespaces">Namespaces</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-permissions">Permissions</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-persistent-topics">Persistent topics</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-non-persistent-topics">Non-Persistent topics</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-partitioned-topics">Partitioned topics</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-non-partitioned-topics">Non-Partitioned topics</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-schemas">Schemas</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/admin-api-functions">Functions</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Adaptors</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/adaptors-kafka">Kafka client wrapper</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/adaptors-spark">Apache Spark</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/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/2.6.4/cookbooks-tiered-storage">Tiered Storage</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/cookbooks-compaction">Topic compaction</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/cookbooks-deduplication">Message deduplication</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/cookbooks-non-persistent">Non-persistent messaging</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/cookbooks-partitioned">Partitioned Topics</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/cookbooks-retention-expiry">Message retention and expiry</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/cookbooks-encryption">Encryption</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/cookbooks-message-queue">Message queue</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/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/2.6.4/develop-tools">Simulation tools</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/developing-binary-protocol">Binary protocol</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/develop-schema">Custom schema storage</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/develop-load-manager">Modular load manager</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/develop-cpp">Building Pulsar C++ client</a></li></ul></div><div class="navGroup"><h3 class="navGroupCategoryTitle">Reference</h3><ul class=""><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/reference-terminology">Terminology</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/reference-cli-tools">Pulsar CLI tools</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/reference-configuration">Pulsar configuration</a></li><li class="navListItem"><a class="navItem" href="/docs/en/2.6.4/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/schema-manage.md" target="_blank" rel="noreferrer noopener">Edit</a><h1 id="__docusaurus" class="postHeaderTitle">Manage schema</h1></header><article><div><span><p>This guide demonstrates the ways to manage schemas:</p>
<ul>
<li><p>Automatically</p>
<ul>
<li><a href="#schema-autoupdate">Schema AutoUpdate</a></li>
</ul></li>
<li><p>Manually</p>
<ul>
<li><p><a href="#schema-manual-management">Schema manual management</a></p></li>
<li><p><a href="#custom-schema-storage">Custom schema storage</a></p></li>
</ul></li>
</ul>
<h2><a class="anchor" aria-hidden="true" id="schema-autoupdate"></a><a href="#schema-autoupdate" 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>Schema AutoUpdate</h2>
<p>If a schema passes the schema compatibility check, Pulsar producer automatically updates this schema to the topic it produces by default.</p>
<h3><a class="anchor" aria-hidden="true" id="autoupdate-for-producer"></a><a href="#autoupdate-for-producer" 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>AutoUpdate for producer</h3>
<p>For a producer, the <code>AutoUpdate</code> happens in the following cases:</p>
<ul>
<li><p>If a <strong>topic doesn’t have a schema</strong>, Pulsar registers a schema automatically.</p></li>
<li><p>If a <strong>topic has a schema</strong>:</p>
<ul>
<li><p>If a <strong>producer doesn’t carry a schema</strong>:</p>
<ul>
<li><p>If <code>isSchemaValidationEnforced</code> or <code>schemaValidationEnforced</code> is <strong>disabled</strong> in the namespace to which the topic belongs, the producer is allowed to connect to the topic and produce data.</p></li>
<li><p>If <code>isSchemaValidationEnforced</code> or <code>schemaValidationEnforced</code> is <strong>enabled</strong> in the namespace to which the topic belongs, the producer is rejected and disconnected.</p></li>
</ul></li>
<li><p>If a <strong>producer carries a schema</strong>:</p>
<p>A broker performs the compatibility check based on the configured compatibility check strategy of the namespace to which the topic belongs.</p>
<ul>
<li><p>If the schema is registered, a producer is connected to a broker.</p></li>
<li><p>If the schema is not registered:</p>
<ul>
<li><p>If <code>isAllowAutoUpdateSchema</code> sets to <strong>false</strong>, the producer is rejected to connect to a broker.</p></li>
<li><p>If <code>isAllowAutoUpdateSchema</code> sets to <strong>true</strong>:</p>
<ul>
<li><p>If the schema passes the compatibility check, then the broker registers a new schema automatically for the topic and the producer is connected.</p></li>
<li><p>If the schema does not pass the compatibility check, then the broker does not register a schema and the producer is rejected to connect to a broker.</p></li>
</ul></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
<p><img src="/docs/assets/schema-producer.png" alt="AutoUpdate Producer"></p>
<h3><a class="anchor" aria-hidden="true" id="autoupdate-for-consumer"></a><a href="#autoupdate-for-consumer" 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>AutoUpdate for consumer</h3>
<p>For a consumer, the <code>AutoUpdate</code> happens in the following cases:</p>
<ul>
<li><p>If a <strong>consumer connects to a topic without a schema</strong> (which means the consumer receiving raw bytes), the consumer can connect to the topic successfully without doing any compatibility check.</p></li>
<li><p>If a <strong>consumer connects to a topic with a schema</strong>.</p>
<ul>
<li><p>If a topic does not have all of them (a schema/data/a local consumer and a local producer):</p>
<ul>
<li><p>If <code>isAllowAutoUpdateSchema</code> sets to <strong>true</strong>, then the consumer registers a schema and it is connected to a broker.</p></li>
<li><p>If <code>isAllowAutoUpdateSchema</code> sets to <strong>false</strong>, then the consumer is rejected to connect to a broker.</p></li>
</ul></li>
<li><p>If a topic has one of them (a schema/data/a local consumer and a local producer), then the schema compatibility check is performed.</p>
<ul>
<li><p>If the schema passes the compatibility check, then the consumer is connected to the broker.</p></li>
<li><p>If the schema does not pass the compatibility check, then the consumer is rejected to connect to the broker.</p></li>
</ul></li>
</ul></li>
</ul>
<p><img src="/docs/assets/schema-consumer.png" alt="AutoUpdate Consumer"></p>
<h3><a class="anchor" aria-hidden="true" id="manage-autoupdate-strategy"></a><a href="#manage-autoupdate-strategy" 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>Manage AutoUpdate strategy</h3>
<p>You can use the <code>pulsar-admin</code> command to manage the <code>AutoUpdate</code> strategy as below:</p>
<ul>
<li><p><a href="#enable-autoupdate">Enable AutoUpdate</a></p></li>
<li><p><a href="#disable-autoupdate">Disable AutoUpdate</a></p></li>
<li><p><a href="#adjust-compatibility">Adjust compatibility</a></p></li>
</ul>
<h4><a class="anchor" aria-hidden="true" id="enable-autoupdate"></a><a href="#enable-autoupdate" 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>Enable AutoUpdate</h4>
<p>To enable <code>AutoUpdate</code> on a namespace, you can use the <code>pulsar-admin</code> command.</p>
<pre><code class="hljs css language-bash">bin/pulsar-admin namespaces <span class="hljs-built_in">set</span>-is-allow-auto-update-schema --<span class="hljs-built_in">enable</span> tenant/namespace
</code></pre>
<h4><a class="anchor" aria-hidden="true" id="disable-autoupdate"></a><a href="#disable-autoupdate" 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>Disable AutoUpdate</h4>
<p>To disable <code>AutoUpdate</code> on a namespace, you can use the <code>pulsar-admin</code> command.</p>
<pre><code class="hljs css language-bash">bin/pulsar-admin namespaces <span class="hljs-built_in">set</span>-is-allow-auto-update-schema --<span class="hljs-built_in">disable</span> tenant/namespace
</code></pre>
<p>Once the <code>AutoUpdate</code> is disabled, you can only register a new schema using the <code>pulsar-admin</code> command.</p>
<h4><a class="anchor" aria-hidden="true" id="adjust-compatibility"></a><a href="#adjust-compatibility" 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>Adjust compatibility</h4>
<p>To adjust the schema compatibility level on a namespace, you can use the <code>pulsar-admin</code> command.</p>
<pre><code class="hljs css language-bash">bin/pulsar-admin namespaces <span class="hljs-built_in">set</span>-schema-compatibility-strategy --compatibility &lt;compatibility-level&gt; tenant/namespace
</code></pre>
<h3><a class="anchor" aria-hidden="true" id="schema-validation"></a><a href="#schema-validation" 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>Schema validation</h3>
<p>By default, <code>schemaValidationEnforced</code> is <strong>disabled</strong> for producers:</p>
<ul>
<li><p>This means a producer without a schema can produce any kind of messages to a topic with schemas, which may result in producing trash data to the topic.</p></li>
<li><p>This allows non-java language clients that don’t support schema can produce messages to a topic with schemas.</p></li>
</ul>
<p>However, if you want a stronger guarantee on the topics with schemas, you can enable <code>schemaValidationEnforced</code> across the whole cluster or on a per-namespace basis.</p>
<h4><a class="anchor" aria-hidden="true" id="enable-schema-validation"></a><a href="#enable-schema-validation" 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>Enable schema validation</h4>
<p>To enable <code>schemaValidationEnforced</code> on a namespace, you can use the <code>pulsar-admin</code> command.</p>
<pre><code class="hljs css language-bash">bin/pulsar-admin namespaces <span class="hljs-built_in">set</span>-schema-validation-enforce --<span class="hljs-built_in">enable</span> tenant/namespace
</code></pre>
<h4><a class="anchor" aria-hidden="true" id="disable-schema-validation"></a><a href="#disable-schema-validation" 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>Disable schema validation</h4>
<p>To disable <code>schemaValidationEnforced</code> on a namespace, you can use the <code>pulsar-admin</code> command.</p>
<pre><code class="hljs css language-bash">bin/pulsar-admin namespaces <span class="hljs-built_in">set</span>-schema-validation-enforce --<span class="hljs-built_in">disable</span> tenant/namespace
</code></pre>
<h2><a class="anchor" aria-hidden="true" id="schema-manual-management"></a><a href="#schema-manual-management" 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>Schema manual management</h2>
<p>To manage schemas, you can use one of the following methods.</p>
<table style="table">
<tr>
<th>Method</th>
<th>Description</th>
</tr>
<tr>
<td>
<p><strong>Admin CLI</strong>
</td>
<td>
You can use the <code>pulsar-admin</code> tool to manage Pulsar schemas, brokers, clusters, sources, sinks, topics, tenants and so on.</p>
<p>For more information about how to use the <code>pulsar-admin</code> tool, see <a href="/docs/en/2.6.4/reference-pulsar-admin">here</a>.
</td></p>
</tr>
<tr>
<td>
<p><strong>REST API</strong>
</td>
<td></p>
<p>Pulsar exposes schema related management API in Pulsar’s admin RESTful API. You can access the admin RESTful endpoint directly to manage schemas.</p>
<p>For more information about how to use the Pulsar REST API, see <a href="http://pulsar.apache.org/admin-rest-api/">here</a>.
</td></p>
</tr>
<tr>
<td>
<p><strong>Java Admin API</strong>
</td>
<td>Pulsar provides Java admin library.</td></p>
</tr>
</table>
<h3><a class="anchor" aria-hidden="true" id="upload-a-schema"></a><a href="#upload-a-schema" 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>Upload a schema</h3>
<p>To upload (register) a new schema for a topic, you can use one of the following methods.</p>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-9320-tab-9321" class="nav-link active" data-group="group_9320" data-tab="tab-group-9320-content-9321">Admin CLI</div><div id="tab-group-9320-tab-9322" class="nav-link" data-group="group_9320" data-tab="tab-group-9320-content-9322">REST API</div><div id="tab-group-9320-tab-9323" class="nav-link" data-group="group_9320" data-tab="tab-group-9320-content-9323">Java Admin API</div></div><div class="tab-content"><div id="tab-group-9320-content-9321" class="tab-pane active" data-group="group_9320" tabindex="-1"><div><span><p>Use the <code>upload</code> subcommand.</p>
<pre><code class="hljs css language-bash">$ pulsar-admin schemas upload --filename &lt;schema-definition-file&gt; &lt;topic-name&gt;<br /></code></pre>
<p>The <code>schema-definition-file</code> is in JSON format.</p>
<pre><code class="hljs css language-json">{<br /> <span class="hljs-attr">"type"</span>: <span class="hljs-string">"&lt;schema-type&gt;"</span>,<br /> <span class="hljs-attr">"schema"</span>: <span class="hljs-string">"&lt;an-utf8-encoded-string-of-schema-definition-data&gt;"</span>,<br /> <span class="hljs-attr">"properties"</span>: {} <span class="hljs-comment">// the properties associated with the schema</span><br />}<br /></code></pre>
<p>The <code>schema-definition-file</code> includes the following fields:</p>
<table style="table">
<tr>
<th>Field</th>
<th>Description</th>
</tr>
<tr>
<td>
<p><code>type</code>
</td>
<td>
The schema type.</td></p>
</tr>
<tr>
<td>
<p><code>schema</code>
</td>
<td></p>
<p>The schema definition data, which is encoded in UTF 8 charset.</p>
<ul>
<li><p>If the schema is a <strong>primitive</strong> schema, this field should be blank.</p></li>
<li><p>If the schema is a <strong>struct</strong> schema, this field should be a JSON string of the Avro schema definition.</p>
</td>
</tr>
<tr>
<td>
<p><code>properties</code>
</td>
<td>The additional properties associated with the schema.</td></p>
</tr>
</table>
</li>
</ul>
<p>Here are examples of the <code>schema-definition-file</code> for a JSON schema.</p>
<p><strong>Example 1</strong></p>
<pre><code class="hljs css language-json">{<br /> <span class="hljs-attr">"type"</span>: <span class="hljs-string">"JSON"</span>,<br /> <span class="hljs-attr">"schema"</span>: <span class="hljs-string">"{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"com.foo\",\"fields\":[{\"name\":\"file1\",\"type\":[\"null\",\"string\"],\"default\":null},{\"name\":\"file2\",\"type\":\"string\",\"default\":null},{\"name\":\"file3\",\"type\":[\"null\",\"string\"],\"default\":\"dfdf\"}]}"</span>,<br /> <span class="hljs-attr">"properties"</span>: {}<br />}<br /></code></pre>
<p><strong>Example 2</strong></p>
<pre><code class="hljs css language-json">{<br /> <span class="hljs-attr">"type"</span>: <span class="hljs-string">"STRING"</span>,<br /> <span class="hljs-attr">"schema"</span>: <span class="hljs-string">""</span>,<br /> <span class="hljs-attr">"properties"</span>: {<br /> <span class="hljs-attr">"key1"</span>: <span class="hljs-string">"value1"</span><br /> }<br />}<br /></code></pre>
</span></div></div><div id="tab-group-9320-content-9322" class="tab-pane" data-group="group_9320" tabindex="-1"><div><span><p>Send a <code>POST</code> request to this endpoint: <a href="https://pulsar.apache.org/admin-rest-api#operation/uploadSchema?version=2.6.4&amp;apiVersion=v2"><b>POST</b> <i>/admin/v2/schemas/:tenant/:namespace/:topic/schema</i></a>
</p>
<p>The post payload is in JSON format.</p>
<pre><code class="hljs css language-json">{<br /> <span class="hljs-attr">"type"</span>: <span class="hljs-string">"&lt;schema-type&gt;"</span>,<br /> <span class="hljs-attr">"schema"</span>: <span class="hljs-string">"&lt;an-utf8-encoded-string-of-schema-definition-data&gt;"</span>,<br /> <span class="hljs-attr">"properties"</span>: {} <span class="hljs-comment">// the properties associated with the schema</span><br />}<br /></code></pre>
<p>The post payload includes the following fields:</p>
<table style="table">
<tr>
<th>Field</th>
<th>Description</th>
</tr>
<tr>
<td>
<p><code>type</code>
</td>
<td>
The schema type.</td></p>
</tr>
<tr>
<td>
<p><code>schema</code>
</td>
<td>
The schema definition data, which is encoded in UTF 8 charset.</p>
<ul>
<li><p>If the schema is a <strong>primitive</strong> schema, this field should be blank.</p></li>
<li><p>If the schema is a <strong>struct</strong> schema, this field should be a JSON string of the Avro schema definition.</p>
</td>
</tr>
<tr>
<td>
<p><code>properties</code>
</td>
<td>The additional properties associated with the schema.</td></p>
</tr>
</table>
</li>
</ul>
</span></div></div><div id="tab-group-9320-content-9323" class="tab-pane" data-group="group_9320" tabindex="-1"><div><span><pre><code class="hljs css language-java"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">createSchema</span><span class="hljs-params">(String topic, PostSchemaPayload schemaPayload)</span><br /></span></code></pre>
<p>The <code>PostSchemaPayload</code> includes the following fields:</p>
<table style="table">
<tr>
<th>Field</th>
<th>Description</th>
</tr>
<tr>
<td>
<p><code>type</code>
</td>
<td>
The schema type.</td></p>
</tr>
<tr>
<td>
<p><code>schema</code>
</td>
<td>
The schema definition data, which is encoded in UTF 8 charset.</p>
<ul>
<li><p>If the schema is a <strong>primitive</strong> schema, this field should be blank.</p></li>
<li><p>If the schema is a <strong>struct</strong> schema, this field should be a JSON string of the Avro schema definition.</p>
</td>
</tr>
<tr>
<td>
<p><code>properties</code>
</td>
<td>The additional properties associated with the schema.</td></p>
</tr>
</table>
</li>
</ul>
<p>Here is an example of <code>PostSchemaPayload</code>:</p>
<pre><code class="hljs css language-java">PulsarAdmin admin = …;<br /><br />PostSchemaPayload payload = <span class="hljs-keyword">new</span> PostSchemaPayload();<br />payload.setType(<span class="hljs-string">"INT8"</span>);<br />payload.setSchema(<span class="hljs-string">""</span>);<br /><br />admin.createSchema(<span class="hljs-string">"my-tenant/my-ns/my-topic"</span>, payload); <br /></code></pre>
</span></div></div></div></div>
<h3><a class="anchor" aria-hidden="true" id="get-a-schema-latest"></a><a href="#get-a-schema-latest" 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 a schema (latest)</h3>
<p>To get the latest schema for a topic, you can use one of the following methods.</p>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-9324-tab-9325" class="nav-link active" data-group="group_9324" data-tab="tab-group-9324-content-9325">Admin CLI</div><div id="tab-group-9324-tab-9326" class="nav-link" data-group="group_9324" data-tab="tab-group-9324-content-9326">REST API</div><div id="tab-group-9324-tab-9327" class="nav-link" data-group="group_9324" data-tab="tab-group-9324-content-9327">Java Admin API</div></div><div class="tab-content"><div id="tab-group-9324-content-9325" class="tab-pane active" data-group="group_9324" tabindex="-1"><div><span><p>Use the <code>get</code> subcommand.</p>
<pre><code class="hljs css language-bash">$ pulsar-admin schemas get &lt;topic-name&gt;<br /><br />{<br /> <span class="hljs-string">"version"</span>: 0,<br /> <span class="hljs-string">"type"</span>: <span class="hljs-string">"String"</span>,<br /> <span class="hljs-string">"timestamp"</span>: 0,<br /> <span class="hljs-string">"data"</span>: <span class="hljs-string">"string"</span>,<br /> <span class="hljs-string">"properties"</span>: {<br /> <span class="hljs-string">"property1"</span>: <span class="hljs-string">"string"</span>,<br /> <span class="hljs-string">"property2"</span>: <span class="hljs-string">"string"</span><br /> }<br />}<br /></code></pre>
</span></div></div><div id="tab-group-9324-content-9326" class="tab-pane" data-group="group_9324" tabindex="-1"><div><span><p>Send a <code>GET</code> request to this endpoint: <a href="https://pulsar.apache.org/admin-rest-api#operation/getSchema?version=2.6.4&amp;apiVersion=v2"><b>GET</b> <i>/admin/v2/schemas/:tenant/:namespace/:topic/schema</i></a>
</p>
<p>Here is an example of a response, which is returned in JSON format.</p>
<pre><code class="hljs css language-json">{<br /> <span class="hljs-attr">"version"</span>: <span class="hljs-string">"&lt;the-version-number-of-the-schema&gt;"</span>,<br /> <span class="hljs-attr">"type"</span>: <span class="hljs-string">"&lt;the-schema-type&gt;"</span>,<br /> <span class="hljs-attr">"timestamp"</span>: <span class="hljs-string">"&lt;the-creation-timestamp-of-the-version-of-the-schema&gt;"</span>,<br /> <span class="hljs-attr">"data"</span>: <span class="hljs-string">"&lt;an-utf8-encoded-string-of-schema-definition-data&gt;"</span>,<br /> <span class="hljs-attr">"properties"</span>: {} <span class="hljs-comment">// the properties associated with the schema</span><br />}<br /></code></pre>
<p>The response includes the following fields:</p>
<table style="table">
<tr>
<th>Field</th>
<th>Description</th>
</tr>
<tr>
<td>
<p><code>version</code>
</td>
<td>
The schema version, which is a long number.</td></p>
</tr>
<tr>
<td>
<p><code>type</code>
</td>
<td>
The schema type.</td></p>
</tr>
<tr>
<td>
<p><code>timestamp</code>
</td>
<td>
The timestamp of creating this version of schema.</td></p>
</tr>
<tr>
<td>
<p><code>data</code>
</td>
<td>
The schema definition data, which is encoded in UTF 8 charset.</p>
<ul>
<li><p>If the schema is a <strong>primitive</strong> schema, this field should be blank.</p></li>
<li><p>If the schema is a <strong>struct</strong> schema, this field should be a JSON string of the Avro schema definition.</p>
</td>
</tr>
<tr>
<td>
<p><code>properties</code>
</td>
<td>The additional properties associated with the schema.</td></p>
</tr>
</table>
</li>
</ul>
</span></div></div><div id="tab-group-9324-content-9327" class="tab-pane" data-group="group_9324" tabindex="-1"><div><span><pre><code class="hljs css language-java"><span class="hljs-function">SchemaInfo <span class="hljs-title">createSchema</span><span class="hljs-params">(String topic)</span><br /></span></code></pre>
<p>The <code>SchemaInfo</code> includes the following fields:</p>
<table style="table">
<tr>
<th>Field</th>
<th>Description</th>
</tr>
<tr>
<td>
<p><code>name</code>
</td>
<td>
The schema name.</td></p>
</tr>
<tr>
<td>
<p><code>type</code>
</td>
<td>
The schema type.</td></p>
</tr>
<tr>
<td>
<p><code>schema</code>
</td>
<td>
A byte array of the schema definition data, which is encoded in UTF 8 charset.</p>
<ul>
<li><p>If the schema is a <strong>primitive</strong> schema, this byte array should be empty.</p></li>
<li><p>If the schema is a <strong>struct</strong> schema, this field should be a JSON string of the Avro schema definition converted to a byte array.</p>
</td>
</tr>
<tr>
<td>
<p><code>properties</code>
</td>
<td>The additional properties associated with the schema.</td></p>
</tr>
</table>
</li>
</ul>
<p>Here is an example of <code>SchemaInfo</code>:</p>
<pre><code class="hljs css language-java">PulsarAdmin admin = …;<br /><br />SchemaInfo si = admin.getSchema(<span class="hljs-string">"my-tenant/my-ns/my-topic"</span>); <br /></code></pre>
</span></div></div></div></div>
<h3><a class="anchor" aria-hidden="true" id="get-a-schema-specific"></a><a href="#get-a-schema-specific" 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 a schema (specific)</h3>
<p>To get a specific version of a schema, you can use one of the following methods.</p>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-9328-tab-9329" class="nav-link active" data-group="group_9328" data-tab="tab-group-9328-content-9329">Admin CLI</div><div id="tab-group-9328-tab-9330" class="nav-link" data-group="group_9328" data-tab="tab-group-9328-content-9330">REST API</div><div id="tab-group-9328-tab-9331" class="nav-link" data-group="group_9328" data-tab="tab-group-9328-content-9331">Java Admin API</div></div><div class="tab-content"><div id="tab-group-9328-content-9329" class="tab-pane active" data-group="group_9328" tabindex="-1"><div><span><p>Use the <code>get</code> subcommand.</p>
<pre><code class="hljs css language-bash">$ pulsar-admin schemas get &lt;topic-name&gt; --version=&lt;version&gt; <br /></code></pre>
</span></div></div><div id="tab-group-9328-content-9330" class="tab-pane" data-group="group_9328" tabindex="-1"><div><span><p>Send a <code>GET</code> request to a schema endpoint: <a href="https://pulsar.apache.org/admin-rest-api#operation/getSchema?version=2.6.4&amp;apiVersion=v2"><b>GET</b> <i>/admin/v2/schemas/:tenant/:namespace/:topic/schema/:version</i></a>
</p>
<p>Here is an example of a response, which is returned in JSON format.</p>
<pre><code class="hljs css language-json">{<br /> <span class="hljs-attr">"version"</span>: <span class="hljs-string">"&lt;the-version-number-of-the-schema&gt;"</span>,<br /> <span class="hljs-attr">"type"</span>: <span class="hljs-string">"&lt;the-schema-type&gt;"</span>,<br /> <span class="hljs-attr">"timestamp"</span>: <span class="hljs-string">"&lt;the-creation-timestamp-of-the-version-of-the-schema&gt;"</span>,<br /> <span class="hljs-attr">"data"</span>: <span class="hljs-string">"&lt;an-utf8-encoded-string-of-schema-definition-data&gt;"</span>,<br /> <span class="hljs-attr">"properties"</span>: {} <span class="hljs-comment">// the properties associated with the schema</span><br />}<br /></code></pre>
<p>The response includes the following fields:</p>
<table style="table">
<tr>
<th>Field</th>
<th>Description</th>
</tr>
<tr>
<td>
<p><code>version</code>
</td>
<td>
The schema version, which is a long number.</td></p>
</tr>
<tr>
<td>
<p><code>type</code>
</td>
<td>
The schema type.</td></p>
</tr>
<tr>
<td>
<p><code>timestamp</code>
</td>
<td>
The timestamp of creating this version of schema.</td></p>
</tr>
<tr>
<td>
<p><code>data</code>
</td>
<td>
The schema definition data, which is encoded in UTF 8 charset.</p>
<ul>
<li><p>If the schema is a <strong>primitive</strong> schema, this field should be blank.</p></li>
<li><p>If the schema is a <strong>struct</strong> schema, this field should be a JSON string of the Avro schema definition.</p>
</td>
</tr>
<tr>
<td>
<p><code>properties</code>
</td>
<td>The additional properties associated with the schema.</td></p>
</tr>
</table>
</li>
</ul>
</span></div></div><div id="tab-group-9328-content-9331" class="tab-pane" data-group="group_9328" tabindex="-1"><div><span><pre><code class="hljs css language-java"><span class="hljs-function">SchemaInfo <span class="hljs-title">createSchema</span><span class="hljs-params">(String topic, <span class="hljs-keyword">long</span> version)</span><br /></span></code></pre>
<p>The <code>SchemaInfo</code> includes the following fields:</p>
<table style="table">
<tr>
<th>Field</th>
<th>Description</th>
</tr>
<tr>
<td>
<p><code>name</code>
</td>
<td>The schema name.</td></p>
</tr>
<tr>
<td>
<p><code>type</code>
</td>
<td>The schema type.</td></p>
</tr>
<tr>
<td>
<p><code>schema</code>
</td>
<td>
A byte array of the schema definition data, which is encoded in UTF 8.</p>
<ul>
<li><p>If the schema is a <strong>primitive</strong> schema, this byte array should be empty.</p></li>
<li><p>If the schema is a <strong>struct</strong> schema, this field should be a JSON string of the Avro schema definition converted to a byte array.</p>
</td>
</tr>
<tr>
<td>
<p><code>properties</code>
</td>
<td>The additional properties associated with the schema.</td></p>
</tr>
</table>
</li>
</ul>
<p>Here is an example of <code>SchemaInfo</code>:</p>
<pre><code class="hljs css language-java">PulsarAdmin admin = …;<br /><br />SchemaInfo si = admin.getSchema(<span class="hljs-string">"my-tenant/my-ns/my-topic"</span>, <span class="hljs-number">1L</span>);<br /></code></pre>
</span></div></div></div></div>
<h3><a class="anchor" aria-hidden="true" id="extract-a-schema"></a><a href="#extract-a-schema" 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>Extract a schema</h3>
<p>To provide a schema via a topic, you can use the following method.</p>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-9332-tab-9333" class="nav-link active" data-group="group_9332" data-tab="tab-group-9332-content-9333">Admin CLI</div></div><div class="tab-content"><div id="tab-group-9332-content-9333" class="tab-pane active" data-group="group_9332" tabindex="-1"><div><span><p>Use the <code>extract</code> subcommand.</p>
<pre><code class="hljs css language-bash">$ pulsar-admin schemas extract --classname &lt;class-name&gt; --jar &lt;jar-path&gt; --<span class="hljs-built_in">type</span> &lt;<span class="hljs-built_in">type</span>-name&gt;<br /></code></pre>
</span></div></div></div></div>
<h3><a class="anchor" aria-hidden="true" id="delete-a-schema"></a><a href="#delete-a-schema" 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 a schema</h3>
<p>To delete a schema for a topic, you can use one of the following methods.</p>
<blockquote>
<h4><a class="anchor" aria-hidden="true" id="note"></a><a href="#note" 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>Note</h4>
<p>In any case, the <strong>delete</strong> action deletes <strong>all versions</strong> of a schema registered for a topic.</p>
</blockquote>
<div class="tabs"><div class="nav-tabs"><div id="tab-group-9334-tab-9335" class="nav-link active" data-group="group_9334" data-tab="tab-group-9334-content-9335">Admin CLI</div><div id="tab-group-9334-tab-9336" class="nav-link" data-group="group_9334" data-tab="tab-group-9334-content-9336">REST API</div><div id="tab-group-9334-tab-9337" class="nav-link" data-group="group_9334" data-tab="tab-group-9334-content-9337">Java Admin API</div></div><div class="tab-content"><div id="tab-group-9334-content-9335" class="tab-pane active" data-group="group_9334" tabindex="-1"><div><span><p>Use the <code>delete</code> subcommand.</p>
<pre><code class="hljs css language-bash">$ pulsar-admin schemas delete &lt;topic-name&gt;<br /></code></pre>
</span></div></div><div id="tab-group-9334-content-9336" class="tab-pane" data-group="group_9334" tabindex="-1"><div><span><p>Send a <code>DELETE</code> request to a schema endpoint: <a href="https://pulsar.apache.org/admin-rest-api#operation/deleteSchema?version=2.6.4&amp;apiVersion=v2"><b>DELETE</b> <i>/admin/v2/schemas/:tenant/:namespace/:topic/schema</i></a>
</p>
<p>Here is an example of a response, which is returned in JSON format.</p>
<pre><code class="hljs css language-json">{<br /> <span class="hljs-attr">"version"</span>: <span class="hljs-string">"&lt;the-latest-version-number-of-the-schema&gt;"</span>,<br />}<br /></code></pre>
<p>The response includes the following field:</p>
<table>
<thead>
<tr><th>Field</th><th>Description</th></tr>
</thead>
<tbody>
<tr><td><code>version</code></td><td>The schema version, which is a long number.</td></tr>
</tbody>
</table>
</span></div></div><div id="tab-group-9334-content-9337" class="tab-pane" data-group="group_9334" tabindex="-1"><div><span><pre><code class="hljs css language-java"><span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">deleteSchema</span><span class="hljs-params">(String topic)</span><br /></span></code></pre>
<p>Here is an example of deleting a schema.</p>
<pre><code class="hljs css language-java">PulsarAdmin admin = …;<br /><br />admin.deleteSchema(<span class="hljs-string">"my-tenant/my-ns/my-topic"</span>); <br /></code></pre>
</span></div></div></div></div>
<h2><a class="anchor" aria-hidden="true" id="custom-schema-storage"></a><a href="#custom-schema-storage" 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>Custom schema storage</h2>
<p>By default, Pulsar stores various data types of schemas in <a href="https://bookkeeper.apache.org">Apache BookKeeper</a> deployed alongside Pulsar.</p>
<p>However, you can use another storage system if needed.</p>
<h3><a class="anchor" aria-hidden="true" id="implement"></a><a href="#implement" 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>Implement</h3>
<p>To use a non-default (non-BookKeeper) storage system for Pulsar schemas, you need to implement the following Java interfaces:</p>
<ul>
<li><p><a href="#schemastorage-interface">SchemaStorage interface</a></p></li>
<li><p><a href="#schemastoragefactory-interface">SchemaStorageFactory interface</a></p></li>
</ul>
<h4><a class="anchor" aria-hidden="true" id="schemastorage-interface"></a><a href="#schemastorage-interface" 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>SchemaStorage interface</h4>
<p>The <code>SchemaStorage</code> interface has the following methods:</p>
<pre><code class="hljs css language-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">SchemaStorage</span> </span>{
<span class="hljs-comment">// How schemas are updated</span>
<span class="hljs-function">CompletableFuture&lt;SchemaVersion&gt; <span class="hljs-title">put</span><span class="hljs-params">(String key, <span class="hljs-keyword">byte</span>[] value, <span class="hljs-keyword">byte</span>[] hash)</span></span>;
<span class="hljs-comment">// How schemas are fetched from storage</span>
<span class="hljs-function">CompletableFuture&lt;StoredSchema&gt; <span class="hljs-title">get</span><span class="hljs-params">(String key, SchemaVersion version)</span></span>;
<span class="hljs-comment">// How schemas are deleted</span>
<span class="hljs-function">CompletableFuture&lt;SchemaVersion&gt; <span class="hljs-title">delete</span><span class="hljs-params">(String key)</span></span>;
<span class="hljs-comment">// Utility method for converting a schema version byte array to a SchemaVersion object</span>
<span class="hljs-function">SchemaVersion <span class="hljs-title">versionFromBytes</span><span class="hljs-params">(<span class="hljs-keyword">byte</span>[] version)</span></span>;
<span class="hljs-comment">// Startup behavior for the schema storage client</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">start</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception</span>;
<span class="hljs-comment">// Shutdown behavior for the schema storage client</span>
<span class="hljs-function"><span class="hljs-keyword">void</span> <span class="hljs-title">close</span><span class="hljs-params">()</span> <span class="hljs-keyword">throws</span> Exception</span>;
}
</code></pre>
<blockquote>
<h4><a class="anchor" aria-hidden="true" id="tip"></a><a href="#tip" 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>Tip</h4>
<p>For a complete example of <strong>schema storage</strong> implementation, see <a href="https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorage.java">BookKeeperSchemaStorage</a> class.</p>
</blockquote>
<h4><a class="anchor" aria-hidden="true" id="schemastoragefactory-interface"></a><a href="#schemastoragefactory-interface" 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>SchemaStorageFactory interface</h4>
<p>The <code>SchemaStorageFactory</code> interface has the following method:</p>
<pre><code class="hljs css language-java"><span class="hljs-keyword">public</span> <span class="hljs-class"><span class="hljs-keyword">interface</span> <span class="hljs-title">SchemaStorageFactory</span> </span>{
<span class="hljs-meta">@NotNull</span>
<span class="hljs-function">SchemaStorage <span class="hljs-title">create</span><span class="hljs-params">(PulsarService pulsar)</span> <span class="hljs-keyword">throws</span> Exception</span>;
}
</code></pre>
<blockquote>
<p>Tip</p>
<p>For a complete example of <strong>schema storage factory</strong> implementation, see <a href="https://github.com/apache/pulsar/blob/master/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/schema/BookkeeperSchemaStorageFactory.java">BookKeeperSchemaStorageFactory</a> class.</p>
</blockquote>
<h3><a class="anchor" aria-hidden="true" id="deploy"></a><a href="#deploy" 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>Deploy</h3>
<p>To use your custom schema storage implementation, perform the following steps.</p>
<ol>
<li><p>Package the implementation in a <a href="https://docs.oracle.com/javase/tutorial/deployment/jar/basicsindex.html">JAR</a> file.</p></li>
<li><p>Add the JAR file to the <code>lib</code> folder in your Pulsar binary or source distribution.</p></li>
<li><p>Change the <code>schemaRegistryStorageClassName</code> configuration in <code>broker.conf</code> to your custom factory class.</p></li>
<li><p>Start Pulsar.</p></li>
</ol>
</span></div></article></div><div class="docs-prevnext"><a class="docs-prev button" href="/docs/en/2.6.4/schema-evolution-compatibility"><span class="arrow-prev"></span><span>Schema evolution and compatibility</span></a><a class="docs-next button" href="/docs/en/2.6.4/functions-overview"><span>Overview</span><span class="arrow-next"></span></a></div></div></div><nav class="onPageNav"><ul class="toc-headings"><li><a href="#schema-autoupdate">Schema AutoUpdate</a><ul class="toc-headings"><li><a href="#autoupdate-for-producer">AutoUpdate for producer</a></li><li><a href="#autoupdate-for-consumer">AutoUpdate for consumer</a></li><li><a href="#manage-autoupdate-strategy">Manage AutoUpdate strategy</a></li><li><a href="#schema-validation">Schema validation</a></li></ul></li><li><a href="#schema-manual-management">Schema manual management</a><ul class="toc-headings"><li><a href="#upload-a-schema">Upload a schema</a></li><li><a href="#get-a-schema-latest">Get a schema (latest)</a></li><li><a href="#get-a-schema-specific">Get a schema (specific)</a></li><li><a href="#extract-a-schema">Extract a schema</a></li><li><a href="#delete-a-schema">Delete a schema</a></li></ul></li><li><a href="#custom-schema-storage">Custom schema storage</a><ul class="toc-headings"><li><a href="#implement">Implement</a></li><li><a href="#deploy">Deploy</a></li></ul></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>